reactjs - Avoiding mutiple refs to props in component -
a typical component duplicate props, there best practice props once component? rather set them again in submitform()
class screen3 extends component { constructor() { super(); this.submitform = this.submitform.bind(this); this.onchange = this.onchange.bind(this); } submitform(e) { const age = this.props.age; const gender = this.props.gender; const ethnicity = this.props.ethnicity; .... } onchange(e) { const field = e.target.name; const value = e.target.value; ... } render() { let { age, gender, ethnicity } = this.props; .... const mapstatetoprops = store => { return { age: store.userdetails.age, gender: store.userdetails.gender, ethnicity: store.userdetails.ethnicity }; };
Comments
Post a Comment