react native - Set an immutable whose value is empty list to an empty list -


if set immutable value empty list empty list, seems immutable considered changed. can explain why happening? thought both mean null, should not considered changed.

this question raised when using react native. when state [] set [] again, associated events triggered.

import react, { proptypes } 'react'; import meteor, { createcontainer } 'react-native-meteor'; import chatlistview './chatlistview'; import {connect} 'react-redux'; import { addroomlist, addroom, updatelastmsg } './chatliststate';  const chatlistviewcontainer = (props) => {   const {     listready, rooms, messages,     userid, authtoken,     addroomlist, addroom, updatelastmsg   } = props;   console.log('container', rooms);   console.log('container', messages);   return (     <chatlistview       listready={listready}       rooms={rooms}       messages={messages}       userid={userid}       authtoken={authtoken}       addroomlist={addroomlist}       addroom={addroom}       updatelastmsg={updatelastmsg}     />   ); };  chatlistviewcontainer.proptypes = {   listready: proptypes.bool,   rooms: proptypes.array,   messages: proptypes.array, };  const meteorcontainer = createcontainer(() => {   const handle0 = meteor.subscribe('userchannels', meteor.userid());   const roomhandle = meteor.subscribe('room', 'channels');   const messageshandle = meteor.subscribe('messages', 'general');   return {     listready: roomhandle.ready()&&messageshandle.ready(),  // 2 lines below responsible update of value   // rooms =[], messages =[], equivalent   // rooms =[], messages =[] got executed  // considers immutables changed   // , triggers mechanism of redux      rooms: meteor.collection('room').find(),     messages: meteor.collection('messages').find(),   }; }, chatlistviewcontainer);  export default connect(   state => ({     userid: state.getin(['auth','currentuser','userid']),     authtoken: state.getin(['auth','authenticationtoken'])   }),   dispatch => ({     addroomlist(roomlist) {       dispatch(addroomlist(roomlist));     },     addroom(rid) {       dispatch(addroom(rid));     },     updatelastmsg(msg) {       dispatch(updatelastmsg(msg));     }   }) )(meteorcontainer) 


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

Voice chat over bluetooth between Android & Python (pybluez) -

Integrate jquery-globalize into an ASP.NET Core MVC App -