Epic React V2

Compound Components and Validation

(See readme.mdx)The button is off

This validation fixes the types and add error handles using the best practice for creating a context with custom hook:

function useToggle() {
            const context = use(ToggleContext);
            // context === null
            if (!context) {
              throw new Error(
                'ToggleContext not found. All Toggle components must be render in a <Toggle />',
              ); //Toggle must be used within a ToggleProvider
            }
            return context;
          }

To test and see the error message handler(on console) delete all tags and just leave the tag: (see the error on console)

<ToggleButton />