I understand that is incorrect based on searches from StackOverflow to attach the global state to local state using Redux. Still, I need it to work like this because I can only see data right after refreshing the screen, and this does not meet the requirements.
I am getting the data using:
const { device } = useSelector((state) => state.device);
const [filteredList, setFilteredList] = useState();
useEffect(() => {
dispatch(devices());
}, []);
And setting the device here:
useEffect(() => {
var filteredData = FilterDevicelocation(device);
setFilteredList(filteredData);
}, [selectedDevicelocation]);
See one of the attempts to make it work:
useEffect(() => {
dispatch(devices());
setFilteredList(device);
}, []);