Reputation: 3
I want to only once import the component 'MessageDialog' in the index.js and use it in other pages. So I store the component in the redux. But I get an error when entering the page. I haven't done this. Can I store a component in the redux?
index.js:
import { MessageDialog } from 'miot/ui';
...
let data = {
MessageDialog: <MessageDialog />,
messageDialogOptions: {
title: '我是标题',
message: '我是内容',
cancel: '取消',
confirm: '确认',
cancelable: false,
visible: true
}
};
let store = createStore(reducers, data);
export default class App extends React.Component {
render() {
return (
<Provider store={store}>
<RootStack />
</Provider>
);
}
}
Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
I hope to successfully render the page.
Upvotes: 0
Views: 36
Reputation: 707
Redux is not meant to store components. You should only store props for your components.
Make your component react to datas you are storing in redux instead of trying to store component itself.
Upvotes: 1