Skip to content

Instantly share code, notes, and snippets.

@LuisHCK
Last active February 3, 2021 03:10
Show Gist options
  • Select an option

  • Save LuisHCK/fe0e51ea12f03335ce8219b1c0b7f5e6 to your computer and use it in GitHub Desktop.

Select an option

Save LuisHCK/fe0e51ea12f03335ce8219b1c0b7f5e6 to your computer and use it in GitHub Desktop.
react.md
# 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