React.Freezer
takes a frozen
prop, that, when true
:
- Prevents React from making any mutations to the tree rooted at
children
- Logically unmounts any
children
and event handlers, as ifchildren
was set tonull
Could form the basis for React escape hatches in general. E.g. dangerouslySetInnerHTML
on every HTML Host element could be deprecated and instead be replaced with:
<React.Freezer children={{dangerousRawHTML: '<!-- foo -->'}} />
This could work with server-side rendering, fragments, and hydration by wrapping content similar to Suspense:
<!--F-->
<!-- foo -->
<!--/F-->
Bikeshed me.