I created a project using umi, and configured dva in config : { immer: true, hmr: true, }. If immer is used in the project, it will automatically freeze, and it will appear when modifying the array
Cannot assign to read only property '0' of object '[object Array]'
For this problem
, modify immer to false
Immer has done a very clever thing internally, that is, the nextState generated by produce is frozen (freeze), (Immer uses the Object.freeze method internally, and only freezes the modified part of nextState compared with currentState), so, When modifying nextState directly, an error will be reported. This makes nextState truly immutable.