Я перебираю массив, чтобы настроить мой компонент React input
.Проблема, с которой я сталкиваюсь, заключается в том, что я не знаю, как передать onEmailFilled
как функцию в handle_changes
.
const inputComponentArray= [{id_name : "signin_email", input_label : "Email", input_type : "email", handle_changes: "{onEmailFilled}"}, {id_name : "signin_password", input_label : "Password", input_type : "password", handle_changes: "{onPasswordFilled}"}]
class Test extends Component{
render()
{
{
inputComponentArray.map((object => {
return
<VerticalInputComponent
id_name={object.id_name}
input_label={object.input_label}
input_type={object.input_type}
handle_changes={object.handle_changes} //this is not working because it received a string instead of a function
/>
}
))
}
}
}
Как это или естьЕсть ли лучший способ сделать это?Я использую map
потому, что хочу создать динамическую страницу формы.
Это на VerticalInputComponent.js
, которая является другой страницей.
<input
id={this.props.id_name}
name={this.props.id_name}
className="input-reset ba b--black-20 pa2 mb2 db w-100 lh-copy lh-copy-l lh-copy-m lh-copy-ns"
type={this.props.input_type}
autoComplete="on"
onChange={this.props.handle_changes}
/>