Last active
May 15, 2019 16:19
-
-
Save ryanflorence/87489cfd6d4ea0ca183cf0d09167e2e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function RadioGroup({ onChange, name, children }) { | |
const [state, inputProps] = useRadioGroup(name) | |
return ( | |
<Context.Provider value={inputProps}> | |
{children} | |
</Context.Provider> | |
) | |
} | |
function RadioInput(props) { | |
const context = useContext(Context) | |
return ( | |
<label> | |
<input {...props} {...context} /> | |
</label> | |
) | |
} | |
function App() { | |
return ( | |
<RadioGroup name="snack" onChange={handleChange}> | |
<div> | |
<RadioInput label="Popcorn" value="pop-corn" /> | |
</div> | |
<RadioInput label="Popcorn" value="pop-corn" /> | |
<RadioInput label="Popcorn" value="pop-corn" /> | |
</RadioGroup> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment