typescript-cheatsheets/react

[Advanced] Restrict useage of child component only as a child of a particular component

jonathandsouza opened this issue · 3 comments

What cheatsheet is this about? (if applicable)

I want to write a cheatsheet exaplaining a pattern where we can restrict a component only to be used as a descendant of another compnent.

Advanced cheatsheet

What's your issue or idea?
There is a common pattern used in libraries such as RadixUI where we can use Context to restrict useage of a child only as a descendant of another component.

I want to write up a cheatsheet for a minimal implementation of this pattern.

Write here

upload the code accordingly which is related to the origin subject which needs to justify the client and project manager as well..

You're free to make a PR with the pattern you think is missing and we'll review it.

Closing this as it's not an issue, but feel free to create a PR!