Open ellisonbg opened 7 years ago
https://github.com/phosphorjs/phosphor/pull/281 adds support for custom elements in JSX.
A custom element (modeled after React functional/stateless components):
const CustomElement = props => <button onClick={props.onClick}>{props.label}</button>
Rendering a custom element in JSX:
VirtualDOM.render(
<div>
<span>Test</span>
<CustomElement label="Test" onclick={() => { console.log('clicked') }} />
</div>,
node
);
https://github.com/phosphorjs/phosphor/pull/282 switches from no-case to camel-case for element attribute and event names in order support rendering React functional/stateless components using Phosphor's virtualdom.
Should Button
in the example above be CustomElement
?
Yes 😋
We have been able to get TSX syntax working with phosphor's
virtualdom
package. The needed steps are the following:First, add the following lines to you
tsconfig.json
:Second, import the phosphor virtual DOM library:
Third, add this to one of your ts files to provide the types needed:
Then you can name files with the
.tsx
extension and use TSX syntax.@blink1073 @sccolbert @grantnestor