I have two complex Layouts under Desktop and Mobile that are difficult to merge together.
I want to render them dynamically, depending on screen resolution, but use 1 child component so and it should not re-render.
How can this be done without merging the Layouts into one component?
- I tried usingMemo with a child component in the parent component. Here’s an example:
(See the output in the console. There I output when the child component is mounted and unmounted) - Also tried using React.memo on the child component, but it clearly doesn’t fit due to the fact that it compares props.
- Also tried throwing the child component into the parent component via
{ children }
2