Closed
Description
I'm using these libraries:
react: 16.8.6
redux: 4.0.1
react-redux: 7.0.3
I have a simple component (Typescript):
class ExampleComponent extends React.PureComponent<IProps, {}> {
constructor(props: any) {
super(props);
}
public render() {
return (
<div>
{this.props.name}
</div>
);
}
}
interface IProps{
name: string;
}
const mapStateToProps = (state) => {
return {
name: state.name
};
}
export default connect(mapStateToProps)(ExampleComponent);
And I have a parent component:
import ExampleComponent from './ExampleComponent';
export default class App extends React.PureComponent<{}, {}> {
constructor(props: any) {
super(props);
}
public render() {
return (
<div>
<ExampleComponent />
</div>
);
}
}
For some reason the connect(mapStateToProps)(ExampleComponent)
returns an object
instead of React component.
I am getting an error:
Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function but got: object
Also when I trying to do console.info(typeof connect(mapStateToProps)(ExampleComponent))
it prints object
to the console.
How can I solve this issue?
Metadata
Metadata
Assignees
Labels
No labels