Nicolò Ribaudo 8dacf85859
Lazily initialize and cache constant JSX elements (#12967)
Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2021-03-06 17:33:43 +01:00

13 lines
199 B
JavaScript

var _span;
let foo = 'hello';
const mutate = () => {
foo = 'goodbye';
};
export const Component = () => {
if (Math.random() > 0.5) mutate();
return _span || (_span = <span>{foo}</span>);
};