ок, это ошибка, но проблема не решается export function usePersistedReducer<State, Action>( reducer: (state: State, action: Action) => State, initialState: State, storageKey: string ) { const [state, dispatch] = useReducer(reducer, initialState, init) const prevState = usePrevious(state) function init(): State { if (typeof window === 'undefined') { return initialState } const stringState = localStorage.getItem(storageKey) if (stringState) { try { return JSON.parse(stringState) } catch (error) { return initialState } } else { return initialState } } useEffect(() => { const stateEqual = deepEqual(prevState, state) if (!stateEqual) { const stringifiedState = JSON.stringify(state) localStorage.setItem(storageKey, stringifiedState) } }, [state]) return { state, dispatch } }
А что за проблема-то?
вылазит Error: Text content does not match server-rendered HTML. at checkForUnmatchedText Uncaught Error: There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.
Ну хорошо, всё понятно же
Обсуждают сегодня