You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React中使用Redux Saga调用API时遭遇组件渲染类型错误的问题求助

React中使用Redux Saga调用API时遭遇组件渲染类型错误的问题求助

大家好,我最近在学习Redux Saga,跟着教程在StackBlitz上做API调用的实现。一开始遇到了文件路径的问题,试了几种方法总算解决了,结果现在又碰到一个新错误,谷歌搜了好半天都没找到可行的解决办法,想请大家帮忙看看怎么修复。

我遇到的错误信息如下:

Error in /turbo_modules/react-dom@18.2.0/cjs/react-dom.development.js (28439:17)
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of App.

下面是我的App.tsx代码:

import { FC } from 'react';

import './style.css';

import { StateDropdown } from './components/StateDropdown';

import Button from './containers/Button';

import NewsItem from './containers/NewsItem';

import Loading from './containers/Loading';

export const App: FC<{ name: string }> = ({ name }) => {
  return (
    <div>
      <Button />
      <Loading />
      <NewsItem />
      <StateDropdown />
    </div>
  );
};

我的项目里涉及的核心文件还有src/reducers/index.js、src/actions/index.js、src/index.tsx、src/sagas/index.js、src/containers/NewsItem.js、src/containers/Loading.js,目前推测问题出在组件的导入导出环节,但自己排查了半天没找到具体错误点,希望能得到大家的指点。

备注:内容来源于stack exchange,提问作者zi zi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.21 08:43:02