I have an array of object data about a form:
const formFields = [
{
"label": "Current Password",
"type": "password",
"name": "currentPassword",
"placeholder": "Current Password",
"required": true
},
{
"label": "New Password",
"type": "password",
"name": "newPassword1",
"placeholder": "New Password",
"required": true
},
{
"label": "Confirm New Password",
"type": "password",
"name": "newPassword2",
"placeholder": "Confirm New Password",
"required": true
},
]
I have the component that use the array:
return (
<Form>
{
formFields.map(function(data) {
return
<Form.Group className="mb-3">
<Form.Label>{ data["label"] }</Form.Label>
<Form.Control type={ data["type"] } name={ data["name"] } placeholder={ data["placeholder"] } required={ data["required"] } />
</Form.Group>;
})
}
<Button variant="primary" type="submit">
Submit
</Button>
</Form>
)
All i see on the page is a button. No form label and form fields. Supposedly, the map function should create an array of element from the array of object formFields. However, it is not doing it, and the color of the return statement within in it is light, like it's never executed.
return (continues on the next line.