Cannot assign to read only property ‘0‘ of object ‘[object Array]‘ 问题

insert image description here


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.

Supongo que te gusta

Origin blog.csdn.net/weixin_47541876/article/details/124386828
Recomendado
Clasificación