About the toJS method in immutable.js

  1. question

    when I use the toJS method in immutable to turn an array of immutable objects into a normal array, an error occurs

    error message: TypeError: list.toJS is not a function

    the confusing thing is that when I went to yarn start for the first time, he would not make a mistake. He would have it later, and it would be good to restart the server, and then make changes and hot updates and then report an error QAQ

    .
  2. list items

index Code

const newList = list.toJS();

reducer Code

const defaultState = fromJS({
  list: [1,2,3,4,5]
});

should be that you have changed list , and the changed list is not immutable data type. Take a look at the breakpoint


code from defaultState to list?


yarn start will be fine after I restart, which is very strange.


you should modify reducer by dispatch passing action . When you modify list , you should write state.set ("list", fromJS (action.data) , because the data passed by action will automatically become js objects instead of immutable objects, and need to be manually converted to immutable objects

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be1d8d-315b2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be1d8d-315b2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?