-
Notifications
You must be signed in to change notification settings - Fork 252
Uncaught TypeError: Cannot assign to read only property of object '#<Object>' #722
Comments
I am also seeing this problem when trying to 'load' a form |
I've done some investigating and think I know what is causing this. Step 1) dispatch load action const formValue = action.state
? get(action.state, form.$form.model)
: getFormValue(form);
const formUpdates = {
...form.$form,
value: formValue,
};
if (action.silent) {
formUpdates.loadedValue = formValue;
} else {
formUpdates.pristine = false;
} action.state is modelCache[cacheId] - see forms-reducer line 91 return {
...modelReducers,
[key]: (state, action) => strategy.formReducer(model, initialFormState, {
plugins,
...formOptions,
})(state, { ...action, state: modelCache[cacheId] }),
}; Step 2) Dispatch action for model field that doesn't exist in the loaded object EDIT form = i.merge(createInitialState(
formState.$form.model,
tempInitialState(modelPath, initialValue)), formState); and formState contains $form which contains the reference to action.state which is a reference to modelCache[cacheId]. Icepick freezes everything. Step 3) CacheReducer tries to update modelCache function cacheReducer(reducer, model, cacheId) {
return (state, action) => {
const newState = reducer(state, action);
modelCache[cacheId][model] = newState;
return newState;
};
} This fails as modelCache[cacheId] has been frozen. I'm don't fully (or even a little bit) understand the changes make is commit 17f06a5 so I'm not sure what the best solution is. I have forked the repo and will try and write a test for this situation so stay tuned. :-) Cheers |
What have you found? |
Hi David, I hit save a bit too quick |
Created a pull request #727 for this issue. |
If it helps. I seem to have no issues on componentWillReceiveProps. However, setting the load action creator on componentWillMount still throws an error.
Connect
There was an error with componentWillReceiveProps as well until I set the proper model path as mentioned here
So I updated my Form Component model from settings to forms.settings
Then no issue with this the componentWillReceiveProps lifecylce method
|
Test and potential fix for issue #722
I believe this was fixed with #727. Please let me know if the issue persists - I was not able to reproduce it. |
… imports react-dom.
Issue #722 Fixed getField missing error
The Problem
Cannot change field outside of initial data
Steps to Reproduce
actions.load()
incomponentWillMount
.city
but not.cityNotExist
.city
field, work as expected.cityNotExist
, error throwedExpected Behavior
onSubmit
event, result must have bothcity
andcityNotExist
fieldsActual Behavior
city
Reproducible Code Example
Please check this repo https://github.com/dangh/test-rrf
The text was updated successfully, but these errors were encountered: