Skip to content
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

Signal Passing to Component in Array #280

Open
jesseagleboy opened this issue Dec 7, 2022 · 3 comments
Open

Signal Passing to Component in Array #280

jesseagleboy opened this issue Dec 7, 2022 · 3 comments

Comments

@jesseagleboy
Copy link

jesseagleboy commented Dec 7, 2022

Initially, I had a map set up to lay out my components in React and was using Signals to pass data from the top level. However, none of the data derived from the Signals in the children components were updating on changes. Once I took out the mapping of components and explicitly wrote out the layout at the parent level, Signals were working normal again. Is there some sort of block that happens with an array but not with manually writing out the components?

@jesseagleboy
Copy link
Author

I actually solved this issue but raised another issue. Apparently the signals don't update if a component was lazy loaded (React.lazy). My components were hence why the the problem happened before. But if code-splitting and lazy-loading seem like the route to go with, how can one use Signals with a lazy-loaded component?

@sahithyandev
Copy link

sahithyandev commented Dec 12, 2022

I am having the same issue. I am rendering lazily loaded components as pages, and Signals are not working as intended. (I will provide a reproduction soon, if needed)

Are there any workarounds?

@jesseagleboy
Copy link
Author

I wasn't proud of this workaround and may not be helpful with code-splitting or bundle size, but I created a wrapper component. The wrapper (or parent) component would use the regular import x from y syntax of the actual component being used and the wrapper component would be the one that would be lazily loaded.

The component being lazily loaded would be the wrapper component and when mounted, that parent component would regularly import the actual component being used. The signals are all inside the actual component and they would not be used directly in a component being lazily loaded. (If I have time, I will try to create an example)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants