【问题标题】:Usage of React Native Debugger with typescriptReact Native Debugger 与 typescript 的使用
【发布时间】:2020-11-24 22:04:58
【问题描述】:

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

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose

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

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

已尝试将 tsconfig.json 中的密钥 lib 更改为:

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

但错误变为:

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

【问题讨论】:

  • 是你的项目React Native吗?如果是的话,你就不需要这样设置了,直接使用它,React Native Debugger 就会捕捉到它。
  • AmerLLicA 谢谢。有效!文档必须是过时的,因为它说这是必要的。
  • 很高兴它对您有所帮助。我留下了文档的答案。请将其标记为其他未来访问者的正确答案。另外,我对您的问题表示赞成。

标签: typescript react-native react-native-debugger


【解决方案1】:

其实,React Native Debugger 不需要设置。只需使用ReduxReact Native Debugger 就会捕捉到你的状态。

使用__REDUX_DEVTOOLS_EXTENSION_COMPOSE__需要写window. __REDUX_DEVTOOLS_EXTENSION_COMPOSE__,而window对象只供浏览器使用。

【讨论】:

    猜你喜欢
    • 2019-03-27
    • 2021-12-09
    • 1970-01-01
    • 1970-01-01
    • 2018-05-08
    • 2020-03-19
    • 2018-06-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多