Last active
February 3, 2021 03:10
-
-
Save LuisHCK/fe0e51ea12f03335ce8219b1c0b7f5e6 to your computer and use it in GitHub Desktop.
react.md
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
| # Parent.js | |
| ```js | |
| import React from 'react' | |
| export default function Parent() { | |
| const [myState, setMyState] = useState() | |
| return ( | |
| <div> | |
| <ChildComponent onChange={setMyState} /> | |
| <p> | |
| {myState} | |
| </p> | |
| </div> | |
| ) | |
| } | |
| ``` | |
| # Children Component | |
| ```js | |
| import React from 'react' | |
| export default function ChildrenComponent(props) { | |
| return ( | |
| <select onChange={props.onChange}> | |
| <option value="0">Cero</option> | |
| <option value="1">Uno</option> | |
| </select> | |
| ) | |
| } | |
| ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment