2 ms·
I was wondering about that when I read this post this morning. The interface of a React component is very small: it's effectively just a render function with s
by bsimpson 11y ago
I was wondering about that when I read this post this morning.
The interface of a React component is very small: it's effectively just a render function with some lifecycle hooks and an internal setState method. Depending on your data management philosophy, you can even scrap state altogether and leave just the render function:
var View = (props) => <div>{ props.content } </div>;
You could probably write a Polymer-esque library that let you create Web Components with a similar API. I haven't looked into the implementation details of react-{dom, canvas, -native}, but I imagine that's effectively what they do - bridge from that API to the platform's native one. I expect that if Web Components are ever faster or otherwise better than the legacy DOM, such a shim will emerge to make WC as easy to write as React components.