javascript - Redux - how to save input value despite reRender? -
redux - how save input value despite rerender? can put value, save change, 1 point data ago when click 2-nd - 1-st
constructor(props) { super(props); this.fields = {} } .... onchangename(e) { this.fields.tablename_input = e.target.value } onchangeparticipants(e) { this.fields.tableparticipants_select = e.target.value } componentdidupdate(params){ if (params.editing){ console.log(params) let tablename_input = this.fields.tablename_input && this.fields.tablename_input || params.table.name reactdom.finddomnode(this.refs.tablename_input).value = tablename_input let tableparticipants_select = this.fields.tableparticipants_select && this.fields.tableparticipants_select || params.table.participants reactdom.finddomnode(this.refs.tableparticipants_select).value = tableparticipants_select } }
please add code fires saving, think problem it's in how update fields parameter.
but, doing property not good, should keep fields values state, if you're managing through redux, recommend take redux-form, library pretty awesome, , lets manage form fields redux state, useful testing , keep components pure, content in redux state.
Comments
Post a Comment