2

要设置 React Native 调试器,我们必须像这样声明一个作曲家:

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose

const store = createStore(
  rootReducers,
  composeEnhancers(applyMiddleware(thunk))
)

但是当使用 typescript TS Compiler 时说:Cannot find name 'window'.ts(2304)

已经尝试将密钥更改lib为此tsconfig.json

"lib": ["es6", "DOM"]

但是错误变为:

Property '__REDUX_DEVTOOLS_EXTENSION_COMPOSE__' does not exist on type 'Window & typeof globalThis'.ts(2339)
4

1 回答 1

1

实际上,React Native Debugger不需要设置。只需使用React Native Debugger 即可捕获您的状态Redux

使用__REDUX_DEVTOOLS_EXTENSION_COMPOSE__需要写入window. __REDUX_DEVTOOLS_EXTENSION_COMPOSE__window对象仅用于浏览器。

于 2020-08-05T06:57:59.287 回答