This repository was archived by the owner on Sep 21, 2022. It is now read-only.
This repository was archived by the owner on Sep 21, 2022. It is now read-only.
Killing React.createElement #49
Closed
Description
Problem
import React from 'react';
React.createElement();
Solution
Add to ReactDOM.render() and AppRegistry.registerComponent():
function prerender (tempalte) {
if (typeof template !== 'object') {
return template;
}
let { props: { children }} = template;
delete template.props.children;
return React.createElement(template.type, template.props, template.children.map(child => prerender(child)));
}
and
<div className="card">
<span>hello</span>
</div>
will become
({
type: 'div',
props: {
className: 'card',
children: [
{
type: 'span',
children: 'hello'
}
]
}
})
Why
- The importance of semantic markup
- React should not be a dev dependency for small modules it takes too much time to use. More than that if PropTypes will go native now no imports at all except for helpers!!!
Metadata
Metadata
Assignees
Labels
No labels