SolidJSS
SolidJS9mo ago
18 replies
Amir Hossein Hashemi

Understanding `createRoot`

There isn't a lot of accessible and straightforward information about how createRoot works, why it exists, and when it should be used. To my knowledge, it's a relatively advanced topic, and there is rarely a need to use it. I don't have a specific use case for it either, but I wanted to update the documentation, so I need to understand it better first. Specifically, I want to address this issue.

Here are my questions; please provide simple explanations:

1. Why is it named createRoot? Root of what?

Creates a new non-tracked owner scope that doesn't auto-dispose. From the Solid docs.
2. What is an owner scope? What is the difference between an owned scope and an unowned scope?

All Solid code should be wrapped in one of these top level as they ensure that all memory/computations are freed up. From the Solid docs.
3. What are the sources of memory and computations that need to be freed up? What problems can arise if they are not freed?
4. Can you provide an example of how the detachedOwner prop could be useful?
5. Can you provide a practical example of using createRoot with code?

Since this is an advanced topic and I want to ensure accuracy for the documentation, I'm tagging a few individuals who I believe might be knowledgeable about this to draw their attention. I typically do not do this. @ryansolid @devagr @Brendonovich @Atila
GitHub
Official documentation for the Solid ecosystem. Contribute to solidjs/solid-docs development by creating an account on GitHub.
Issues · solidjs/solid-docs
Was this page helpful?