Context scoping clarification #1091
-
Hi Radix team! First of all I would like to congratulate you for the amazing job you have done so far, this library really makes the difference in every aspect. As I said here, I'm planning to invest some time helping, so I'm trying to study every implementation and component that you provide. But I'm having a hard time figuring out how are you handling contexts. Seems that there is an scoping system, but I'm having a hard time understanding its goal. My only guess so far has been that is used for unification and clarity but I don't know If this is really the intention. Thanks in advance and have a great week! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
@luisorbaiceta Thank you. Really pleased that you're having a poke around and look forward to seeing what you contribute! Radix Primitives API is intentionally very open allowing for all sorts of compositions. For example: <AlertDialog.Root>
<Dialog.Root>
<Dialog.Trigger />
<Dialog.Content>
<AlertDialog.Trigger /> {/* note the alert trigger in dialog content */}
</Dialog.Content>
</Dialog.Root>
<AlertDialog.Content />
</AlertDialog.Root> An issue arises here though... The Due to the way React Context works, the composition above would mean the The scoping ensures that There are many advantages to compound components but this is one of the disadvantages unfortunately. If our consumers re-composed one of our components to build out their own separate patterns and then used them together like the above example, they would have similar issues. It would be good to raise this with the React team tbh as they might have better ideas for solutions. Otherwise, we could always try to document our scoping API for consumers to use if they hit this issue themselves. Anyway, hope that helps a little. I'm happy to answer any additional questions you might have on all this because it's a bit of a mind bender 😅 |
Beta Was this translation helpful? Give feedback.
@luisorbaiceta Thank you. Really pleased that you're having a poke around and look forward to seeing what you contribute!
Radix Primitives API is intentionally very open allowing for all sorts of compositions. For example:
An issue arises here though...
The
AlertDialog
is aDialog
composition under the hood with additional functionality bound to meetAlertDialog
requirements. This means thatAlertDialog.Root
is also aDialog.Root
so provides bothD…