Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsx macro can generate also object literals #28

Closed
francescoagati opened this issue Apr 16, 2016 · 3 comments
Closed

jsx macro can generate also object literals #28

francescoagati opened this issue Apr 16, 2016 · 3 comments
Milestone

Comments

@francescoagati
Copy link
Contributor

francescoagati commented Apr 16, 2016

hi,
reading this article https://reactjsnews.com/how-to-make-your-react-apps-10x-faster i have see that react can process object literals for template.
This have some performance,beacuse instead of calling createElement we can simple return the object literal created from createElement at compile time when the macro jsx works.

we could add a flag like -D react-fast-jsx to make retrun object literals from jsx macro instead of React.createElement

Also babel has introduce this new features
`
Babel 5.8.24 introduces Inlining React elements: The optimisation.react.inlineElements transform converts JSX elements to object literals like {type: 'div', props: ...} instead of calls to React.createElement . This should only be enabled in production, since it disables some development warnings/checks.
•Babel 5.8.24 introduces Constant hoisting for React elements: The optimisation.react.constantElements transform hoists element creation to the top level for subtrees that are fully static, which reduces calls to React.createElement and the resulting allocations. More importantly, it tells React that the subtree hasn’t changed so React can completely skip it when reconciling. This should only be enabled in production, since it disables some development warnings/checks.

`

@elsassph
Copy link
Contributor

elsassph commented Apr 16, 2016

It seems object literals could be done reasonably simply: facebook/react#3228

Constants hoisting is much more difficult to apply.
Another possibility offered by Haxe type system: spreads could be resolved as properties instead of having React inspect objects at run time.

Optimizations besides object literals should be moved into separate tickets.

@francescoagati
Copy link
Contributor Author

yes object literal can be done at macro level with a compile flag for activate this feature.

@francescoagati
Copy link
Contributor Author

for me this issue can be closed

@elsassph elsassph added this to the 0.4 milestone Apr 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants