Answer the question
In order to leave comments, you need to log in
How many times is connetc() called?
I watched a video in which the author filters data for state in connect:
connect((state)=>({
state.arrayValues.filter(val => val.includes(a));//массив со строками
}),
(dipatch)=>({})
);
Answer the question
In order to leave comments, you need to log in
In both cases. At the beginning, since the component is probably connected somewhere, and since it is connected (for example, through import MyComp), then all the code will be executed. It is the same in case of changing the "attached" data.
The easiest way to check this is to add console.log and see.
connect( (state)=> {
console.log('вызван connect')
return state.arrayValues.filter(val => val.includes(a));//массив со строками
},
(dipatch)=>({})
);
shouldn't it be like this
connect( (state) => ({ filtered: state.arrayValues.filter(val => val.includes(a)) }) )(MyComponent);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question