Leal
Complex createResource management
Well, the following code still runs only once, in the server or in the client and the data is still transferred to the client if rendered by the server
I'll probably have to refactor half the project to remove the WebSocket, which although is experimental, was actually working fine and move to SSE. I'll probably have to think in a new solution to the problem
Thank you very much for your help (again :P)!
14 replies
Unable to provide context to children
I don't really know when to properly use the children fn, and I don't really remember where I've read that it was a good practice to use it on every component and please, if this is a wrong statement I would love to understand when it's a good thing to use it
Just for the sake of documentation, here's the fixed snippet:
Thank you guys for your help!
13 replies
Unable to provide context to children
Thank you guys for answering and sorry for my delay, had to clean the house followed by a power drop 🥲
Answering your messages, in order:
- Are those snippets in the same module? Yes, I'll be adjusting the code according to your description and make some tests, but if it's really necessary to declare context as locals for each request, then I don't really understood it's objective. The way I understood context was like an Angular component providing some value that is accessible in it's children, therefore the declaration of the context would just be some kind of identifier to the resource but I might be really wrong here.
- You may force props.children to be evaluated before the Context is ready I have tried using props.children instead of the children fn from solid, it had the same result
- So I'd start by isolating the provider and hook into their own module... I'll be doing that
- The problem here is that the children are created early... children() is only used in the snippet provided, and as I said, I have tried using props.children directly
- I suspect there may well be something else be going on in code that we aren't seeing … I'll take the business logic out of the component and provide you guys the hole file
------
As I was writing this answer, based on your suggestions, I was able to fix the problem. It's really a children fn problem. When I tried using
const DropdownContext = createContext<DropdownCtx>();
and both components are in the same module, only the usage part is outside the module.
- Context as a module global isn't good enough if it is used during SSR... I couldn't really find examples on context for SolidStart projets, props.children
I still had the children fn declaration at the beginning of the component and by removing that the problem was fixed!13 replies