How to use Redux Transition Time to handle errors

I’m trying to figure out how to handle errors in a React / Redux application, and found out that Redux allows you to move the state continuum backward due to an immutable state template. Is it a crazy idea to go back in time on Redux if the message fails while at the same time increasing the counter of internal component counts and ultimately sending the necessary actions? How can I go back to the previous state with a contraction reaction?

+4
source share
2 answers

What you are looking for is a template called "optimistic updates." For example, you send an action before a network call under the assumption that the network call will succeed. If the call fails, you send a second action to return the first.

Debugging while traveling requires the use of Redux DevTools. DevTools actually records all submitted actions, and when you skip back and forth in history, it will play back actions to this point to determine what the current state should be. The old actions and old conditions are not recorded in the production (although you, of course, could do something yourself to do something like that).

+2
source

redux chrome UI/UX . decux dev Chrome.

, redux, debux dev. createStore().

, .

, dev-tool .

import { createStore, applyMiddleware, compose } from 'redux';
import createReducer from './reducers';

const devtools = window.devToolsExtension || (() => noop => noop);

export default function configureStore(initialState = {}, middlewares) {
  const enhancers = [
    applyMiddleware(...middlewares),
    devtools(),
  ];

  const store = createStore(
    createReducer(),
    initialState,
    compose(...enhancers)
  );

  return store;
}
-1

Source: https://habr.com/ru/post/1649358/


All Articles