developit / htm

Hyperscript Tagged Markup: JSX alternative using standard tagged templates, with compiler support.
Apache License 2.0
8.67k stars 170 forks source link

React Components #173

Closed spoerri closed 3 years ago

spoerri commented 4 years ago

How can traditional react components be used from htm?

React-widgets seem to work off-the-shelve with preact-compat and jsx, but not with htm...

import { html, Component } from 'htm/preact';
import style from './style';
import Multiselect from 'react-widgets/lib/Multiselect';
import 'react-widgets/dist/css/react-widgets.css';

export default class Profile extends Component {
        render({}, {}) {
//return <div class={style.profile}><Multiselect data={['alphabet','alfalfa','broccoli']} /></div>; //jsx works
return html`<div class=${style.profile}><Multiselect data=${['alphabet','alfalfa','broccoli']} /></div>`; //htm doesn't work yet...
        }
}

Or, how would a javascript noob go about debugging this? In chrome's Elements view, the htm version has this showing up as simply \

spoerri commented 4 years ago

Duh, it needs to be \<${Multiselect}. Created a README PR to make it a little clearer :)