Created
August 10, 2020 09:14
-
-
Save Zeko369/53489acb7cff40e4908fd45242524524 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
const xAxises = [ | |
{ id: 1, name: 'pero' }, | |
{ id: 2, name: 'foobar' } | |
]; | |
const yAxises = [ | |
{ id: 1, name: 'nesto' }, | |
{ id: 2, name: 'slavko' } | |
]; | |
export const TamTam: React.FC = () => { | |
const [x, setX] = useState<number>(); | |
const [y, setY] = useState<number>(); | |
useEffect(() => { | |
setX(1); | |
setY(1); | |
}, []); | |
return ( | |
<div> | |
<h1> | |
SelectedID: {x}, selectedOBJ: {JSON.stringify(xAxises.find((obj) => obj.id === x))} | |
</h1> | |
<select onChange={(e) => setX(parseInt(e.target.value))} value={x}> | |
{xAxises.map((opt) => ( | |
<option key={opt.id} value={opt.id}> | |
{opt.name} | |
</option> | |
))} | |
</select> | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment