-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request]: HeaderContainer should either treat its render children as a function or expose a props pass-through #15975
Comments
Thank you for submitting a feature request. Your proposal is open and will soon be triaged by the Carbon team. |
@lluisrojass Hey I'm just a bit confused here, let me see if I can clarify. You're suggesting that any prop changes you provide to the stuff within Wouldn't a more robust solution be for you to use |
Nope, sorry maybe I can produce an example in a bit, but re-renders to HeaderContainer will produce an unmount/remount to everything being rendered inside the render prop. That is the core issue. |
Hello, here is a repro. You can see the re-mounts with both the log and the image refetching: https://stackblitz.com/edit/github-gab1sd-clhl35?file=src%2FDiceRoll.jsx. We could define a whole Component to pass into Your edit: |
Let's try it! 👍 A PR would be awesome if you're interested |
The Carbon team has accepted this proposal! Our team doesn't have the capacity to work on this now, so we are requesting community contributors. Please see the labels for roles that are needed. If you are willing to help out, comment below and we will get in touch! |
Ok great, seeing this now, will spend some time on this tomorrow |
The problem
The UI Shell
<HeaderContainer />
component expectsrender
to be a React component. Using the render props pattern (shown in the official storybook example here) will trigger un/re-mounting, which also remounts all children, dumping all state.An effective solution might be to hoist state above
<HeaderContainer />
, however this promotes poor organization, and does not handle for all issues (e.g. childimg
sources are re-fetched causing visual jitter). A user could also provide a React component forrender
, with the limitation that it be severed from accessing any local parent state or depend on any external prop, which would only leave room for trivial use cases, or require convoluted workarounds.The solution
We could treat
render
as a function and not a component, however it would represent a non-backwards compatible change which would require a major version upgrade according to semver.A simple, backwards compatible solution would be to expose a props pass-through object in
HeaderContainer
which is spread onto the child component.Examples
No response
Application/PAL
No response
Business priority
Low Priority = release date is not dependent on fix or not upcoming
Available extra resources
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: