Solve the problem of Google Redux DevTools debugging React+Typescript project data not matching/connecting

We built and used the redux environment in the React+Typescript project environment above . We created a redux project environment.
However, when we use the Google Chrome plug-in to debug, we
will find that there is a problem with the mismatched data and we cannot see the data, or we cannot connect
at all . When we click the plus and minus signs to change the value, the debugging tool does not respond.
Insert image description here
We enter it in the terminal.

npm install --save-dev redux-devtools-extension @types/redux-devtools-extension

Introduce dependencies.
Insert image description here
By chance, we introduce the composeWithDevTools function under redux-devtools-extension in index.tsx under store.

Then as the second parameter of enthusiasm

import {
    
     createStore, Reducer } from 'redux';
import {
    
     enthusiasm } from '../reducer/index';
import {
    
     EnthusiasmAction } from '../actions/index';
import {
    
     IStoreState } from '../types/index';
import {
    
     composeWithDevTools } from "redux-devtools-extension"

const initialState: IStoreState = {
    
    
  enthusiasmLevel: 1,
  languageName: 'TypeScript'
};

const store = createStore<IStoreState, EnthusiasmAction, {
    
    }, {
    
    }>(enthusiasm as Reducer<IStoreState, EnthusiasmAction>, initialState,composeWithDevTools());

export default store;

Some versions are written like this.
Insert image description here
Then we start the project again and open the debugging tool,
and we can see the data we actually set.
Insert image description here
Then we click the plus and minus signs to operate the values
. Then our debugger will pop up the new changes.
Insert image description here

Guess you like

Origin blog.csdn.net/weixin_45966674/article/details/133217106