[英]Export not working for connected component in react
class Test extends Component {
render() {
return (
);
}
}
const mapDispatchToProps = dispatch => ({
});
const mapStateToProps = state => {
return {};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(Test);
I got a component like this above.我有一个像上面这样的组件。 I am trying to export it from another file say (index.js) in the below fashion.The path is correct i have checked that.
我正在尝试以下面的方式从另一个文件(例如 index.js)导出它。路径是正确的,我已经检查过了。
export Test from "./test.jsx";
But connected component is not getting exported from this file.但是连接的组件没有从此文件导出。 Am I doing something wrong ?
难道我做错了什么 ? If i am exporting the class and importing it like the following its working
如果我正在导出该类并将其导入如下所示
export {Test} from "./test.jsx";
Try to change this code line below尝试更改下面的此代码行
export Test from "./test.jsx";
Into进入
export { default } from "./test.jsx";
https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export
Have you tried this?你试过这个吗?
import Test from "./test.jsx";
export Test;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.