reactjs - 类型 'Provider<AnyAction>' 丢失

标签 reactjs typescript redux

我正在用 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)

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

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

最佳答案

我的天啊

我的文件名是 index.ts
我把它改成了 index.tsx
现在运作良好。

关于reactjs - 类型 'Provider<AnyAction>' 丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55860861/

相关文章:

javascript - Angular 性能 : ngStyle recalculates on each click on random input

javascript - mapStateToProps 中的 If then 语句

javascript - scrollIntoView 整个页面向下移动

javascript - React 中是否可以重新挂载组件?

javascript - Angular 项目中 angular.json 中的 styles 和 stylePreprocessorOptions 有什么不同

javascript - 将 Redux 与 vanilla JS 结合使用,如何在不将其传递给每个组件的情况下实现它?

reactjs - React Hooks 和 React-Redux 连接 : What is the best practice to make them work together?

javascript - 如何根据从 DOM 接收到的键更新状态数组中的某些对象

reactjs - 在 React 中用 404 图像替换损坏的图像

typescript - 使用异步数据加载将选项设置为在 Angular2 中选择