Linked Questions

Popular Questions

How to add key name and key value from Form?

Asked by At

I'm working on a React app and want the form I'm working on to be able to add key name and key value to sensorProperties: {} (sensorProperties is a part of sensor object). I have to allow user to give a name for both, key and value.

  this.state = {
        sensor: {
            name: '',
            type: '',
            position: '',
            sensorProperties: {}
        show: false,
        key: '',
        value: ''

I added two functions handleValueChange and handleKeyChange. When I invoke console.log(key, value), I see they have my input values, but how can I pass these values to my sensorProperties?

handleKeyChange = (event) => {
    const nKey =
    this.setState({key: nKey})

handleValueChange = (event) => {
    const nValue =
    this.setState({value: nValue})

     <FormControl required type="text" value={key}  

     <FormControl required type="text" value={value} 

Related Questions