I have a Spring-Boot app with a ReactJS front-end, and I'm trying to figure out how to use Semantic UI to use a value selected from one input field to populate another input field.
I think I have most of the pieces in place, but I'm trying to figure out how to select a value from an array of name/value objects based on the name. I haven't quite gotten how the "map" function works, and the examples I've seen so far choose based on an index rather than a value. How to code it so it chooses the entry based on the value?
For example, here's the array:
const productMap = [
{key: 'template_key1', value: 'Product 1'},
{key: 'template_key2', value: 'Product 2'},
{key: 'template_key3', value: 'Product 3'}
}
I have a method that gets called when the user selects the key:
handleSelectTemplateChange=(event,{value})=>{
let item = {...this.state.item};
item.template = value;
// how should this be coded?
item.product = productMap.getValue(item.template);
this.setState({item});
}