Answer the question
In order to leave comments, you need to log in
Field dependency in state tree in redux, how to remove?
I'm taking my first steps in ReactJS, Redux and I can't understand why changing one object in the state tree changes another object, although this is not written in action creators. I have a table with data that receives data using the fetch method, then I select a row and call the edit form. Question why change of the data in the form, changes a line in the table???
Action creators
.........
export function setRowEditable(row) {
return {
type: SET_ROW_EDITABLE,
rowEditable: row
}
}
export function changeRowEditable(fieldName, newValue) {
return (dispatch, getState)=> {
let rowEditable = getState().myForm.rowEditable
rowEditable[fieldName] = newValue
dispatch(setRowEditable(rowEditable))
}
}
export default function myModal(state = initialState, action) {
switch (action.type) {
...........
case SET_ROW_EDITABLE:
return {...state, rowEditable: action.rowEditable}
default:
return state
}
}
Answer the question
In order to leave comments, you need to log in
let rowEditable = getState().myForm.rowEditable
rowEditable[fieldName] = newValue
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question