Is it possible to update state with form items coming from a database in react?

  javascript, reactjs, redux

I am building a react app that contains a form. I get the form items from a database. My state in the component with the form:

    state = {
       //should have form_item.f_id : ''
    }

The form items are an array on the props and I loop through them to display like this:

                    { form_items && form_items
                        .map(form_item => {
                            return (
                                <div className="input-field">
                                    <input 
                                    placeholder={form_item.place_holder}
                                    type="text" 
                                    id={ form_item.f_id }
                                    required
                                    className='validate f-inpt'
                                    onChange={this.handleChange}
                                    />
            
                                    <label htmlFor="full_name" className="active fnt-16">
                                        { form_item.label }
                                    </label>
                                </div>
                            )
                        })
                    }

My challenge is getting the state to pick the ID of the form items. Please help.

Thanks

Source: Ask Javascript Questions

LEAVE A COMMENT