【问题标题】:Type 'Provider<AnyAction>' is missing缺少类型“Provider<AnyAction>”
【发布时间】:2019-09-15 13:39:59
【问题描述】:

我正在用 typescript 做 react 项目。

这是我在 index.ts 中的代码

const store = configureStore(initialStateFromDB);
ReactDOM.render(
  <Provider store={store}>
    <App></App>
  </Provider>,
  document.getElementById('app')
);

我遇到了很多错误!

首先。

Type 'Provider<AnyAction>' is missing the following properties from type 'ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)>[]': length, pop, push, concat, and 25 more.ts(2345)

Conversion of type 'Store<{}, AnyAction> & { dispatch: {}; }' to type 'Provider<AnyAction>' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.ts(2352)

我无法理解这些错误消息的含义。

我应该怎么做才能修复这个错误?

【问题讨论】:

    标签: reactjs typescript redux


    【解决方案1】:

    天哪

    我的文件名是index.ts

    我改成index.tsx

    现在效果很好。

    【讨论】:

    • 经过数小时的努力找到了这个。谢谢。
    猜你喜欢
    • 2021-02-23
    • 2021-07-30
    • 2019-11-19
    • 2019-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-13
    相关资源
    最近更新 更多