great remark, I will have to do my own research on that as your comment gave me some ideas and a different perspective on the whole thing.
By the way, this is far from a "novel" pattern, but it sounds like it might be a lightbulb moment for you in terms of separating concerns.
Take a look at some very popular conditional components that you've probably already used:
MaterialUI's Hidden component: github.com/mui-org/material-ui/blo...
It uses the theme context internally and the media-query props you provide it to determine if a child should be rendered.
React Router's Route component: github.com/ReactTraining/react-rou...
It uses the router context and the path parameter you pass in to determine if the child (or render of Component props) should be rendered.
path
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
great remark, I will have to do my own research on that as your comment gave me some ideas and a different perspective on the whole thing.
By the way, this is far from a "novel" pattern, but it sounds like it might be a lightbulb moment for you in terms of separating concerns.
Take a look at some very popular conditional components that you've probably already used:
MaterialUI's Hidden component: github.com/mui-org/material-ui/blo...
It uses the theme context internally and the media-query props you provide it to determine if a child should be rendered.
React Router's Route component: github.com/ReactTraining/react-rou...
It uses the router context and the
path
parameter you pass in to determine if the child (or render of Component props) should be rendered.