код крюка: < /p>
Код: Выделить всё
function useManager() {
const [isManaged, setManaged] = useState(false)
const dispatch = useAppDispatch() // just a re-export of redux's useDispatch
let stackArray = useAppSelector(stack) // stack is a defined selector (state => state.stack)
const checkArrayLength = () => {
return stack.length > 0;
}
const setManagedState = useCallback(
() => {
if(checkArrayLength()){
console.log(stack.length)
Подробнее здесь: [url]https://stackoverflow.com/questions/79385542/useselector-inside-of-a-hook-doesnt-update-correctly[/url]