【发布时间】:2019-07-14 18:57:41
【问题描述】:
我应该在没有 redux 端的情况下测试组件。我像导入它一样
import { CustomersPage, IProps } from '../Page';
但它返回 Invariant Violation: Element type is invalid: 期望一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:未定义。你可能忘了展示 rt 你的组件从它定义的文件中,或者你可能混淆了默认和命名导入这个错误
然后像export class CustomersPage extends React.Component<IProps> {}一样导出它
并且还导出了 redux 的默认值
export default withRouter<any>(
connect<IStateProps, IDispatchProps>(
(appState: IMainReduxState) => ({
}),
{
},
)(CustomersPage),
);
【问题讨论】:
-
可以给我们看看CustomersPage组件的完整代码吗?
标签: reactjs redux jestjs enzyme redux-saga