I'm practing react redux and I'm making a simple CRUD. I create a searchbox input, and works fine, but when I erased the input, the table with the data dosen 't update. I alrready try save the result into the "search" in the initialState, but still dosen't work. what I'm doing wrong? Thanks!
I upload my code here:
https://codesandbox.io/s/silly-wood-5ni19?fontsize=14&hidenavigation=1&theme=dark
Try to change to:
case "SEARCH_DATA": {
const { event } = action.payload;
let res = [];
if (event) {
res = state.data.filter( el => el.name.toLowerCase().includes(event));
}
return {
...state,
data : res, // here is pass the result of the filter fn
loading: true
};
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.