
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
react-polymer-component
Advanced tools
A generic React.Component for wrapping Polymer Elements and binding events and property data between them
This project represents an experiment to simplify the use of Polymer Elements with React Components but is not intended to for use in a production environment and no longer maintained.
A generic React.Component
for wrapping Polymer Elements and binding events and property data between them. No changes to the element required!
Polymer elements can be wrapped and used in two ways and used just like any other React component in the render()
function:
const React = require('react')
// Generic class for wrapping a Polymer element
const PolymerComponent = require('react-polymer-component')
// Get a class that specifically wraps the element 'my-polymer-element'
const MyPolymerElement = PolymerComponent.bind('my-polymer-element')
class SubComponent extends React.Component {
// ...
render() {
return <div>
// ...
<PolymerComponent element-tag="my-polymer-element"></PolymerElement>
// or
<MyPolymerElement></MyPolymerElement>
// ...
</div>
}
}
Data is bound like all other React properties and set on the Polymer element using the set()
function. The property must exist in the Polymer class' properties
object to be bound. If a bound property is removed or set to undefined
, then the original Polymer property value is used.
<MyPolymerElement items={ this.props.items }></MyPolymerElement>
Events are registered using the existing Polymer convention of prefixing events with on-
, so they can easily be bound to from a React component.
<MyPolymerElement on-my-custom-event={ e => console.log('Event Fired!', e) }></MyPolymerElement>
Slot elements and slotted children work as expected, including using the slot
attribute field.
<MyPolymerElement>
<div slot="special-slot">Slotted Content!</div>
</MyPolymerElement>
The styles passed to the element are applied to the Polymer element directly. CSS variables work to the extent that they work in modern browsers.
<MyPolymerElement style={ { '--color-variable': 'red' } }></MyPolymerElement>
FAQs
A generic React.Component for wrapping Polymer Elements and binding events and property data between them
We found that react-polymer-component demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.