3 ms·
> Break down your React rendering into two steps: "state->JSON", then "JSON->DOM". Er… that's exactly how React works in the first place, your "JSON" is react'
by masklinn 11y ago
> Break down your React rendering into two steps: "state->JSON", then "JSON->DOM".
Er… that's exactly how React works in the first place, your "JSON" is react's "VDOM". The point of the shallow renderer is to perform a single level of rendering rather than recursively rendering all components to the final VDOM (so sub-components will appear as sub-components, not as their rendered vdom)
- zenojevski 11y agoHe means to preprocess your props+state into a simple dictionary, so that you have moved 90% of logic from `render()` to a different, more testable function.
- zodiac 11y agoI think the JSON that drcode describes doesn't need to be DOM-like - it doesn't need to contain spans, divs etc. Look at the example he gave.