AI

Compound components allow you to create expressive APIs like <Toggle><Toggle.On>...</Toggle.On></Toggle> where parent and children share state implicitly.

Your Task:

  • Create a Toggle component that uses createContext to share isOn and toggle state
  • Create Toggle.On that only renders children if isOn is true
  • Create Toggle.Off that only renders children if isOn is false
  • Create Toggle.Button that triggers the toggle
TypeScript Solution
Loading...

Submit your code to see test results