prism-react-renderer
prism-react-renderer copied to clipboard
Render children using jsx syntax
https://github.com/FormidableLabs/prism-react-renderer/blob/86c05728b6cbea735480a8354546da77ae8b00d9/src/components/Highlight.js#L134
In Highlight.js (and probably other parents), children is rendered by calling it as a function. This can cause a subtle but hard-to-find issue depending on user's code.
- If user passes a function component (using hooks) as child, that will fail
- There can be other subtle differences because of how react renders function component lazily now-a-days.
All of that can be solved by just rendering it as jsx, like <Children />
. Then react will treat it as a proper component.
Backwards compat - Because normal functions will work just the same as pure function component, they will continue to work in the same way. It will not break existing userland code.