For React devs: this little snippet gives you a JSX-like interface in pure JavaScript, no transpilation required
const e = type => ( props = {}, children = [], ) => React.createElement(type, props, ...children)
Usage
const P = e('p') const Div = e('div') const Button = e('button') const Clicker = e(({ message }) => { const [clicked, setClicked] = React.useState(0) return Div({ id: 'clicker', style: styles.div, }, [ P(null, [`${message}: clicked ${clicked} times`]), Button({ onClick: () => { setClicked(clicked + 1) }, }, ['click']), ]) }) ReactDOM.render( Clicker({ message: 'You got this!' }), document.getElementById('root'), )
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
For React devs: this little snippet gives you a JSX-like interface in pure JavaScript, no transpilation required
Usage