how to bind a json data which has a key-value pair to select html in reactjs, such that It should display the value in the drop-down and If I choose a value , I should provide the relevant key?
For example:
var optionsdata = [
{key='101',value='Lion'},
{key='102',value='Giraffe'},
{key='103',value='Zebra'},
{key='104',value='Hippo'},
{key='105',value='Penguin'}
];
in the drop-down, it should show "Lion","Giraffe","Zebra",... if I choose, Zebra, I should get the select value (Zebra) as well as the key (103, in the above example)
optionsData, why don't you match it with the selected value to get the key?keyis unique right? then you could thekeyto bevalueof option, like this:<option value={prop.key}>{prop.value}</option>