'How to pass props to a component, exported with Store Provider?
I want to export my react component along with redux store Provider. So, I wrap the component with this exportWithState callback, but I think I'm not dealing with these props the right way? As I'm unable to get props in my component that are passed from the application that is using my component.
export const exportWithState = (Component) => (props) => {
return (
<Provider store={store}>
<Component props />
</Provider>
)
}
import {MyComponent} from "./components/my-component";
const MyComponentWithState=exportWithState(MyComponent);
export {MyComponentWithState};
Are the props passed from the Application that is using my component should be at the second arrow of callback?
Solution 1:[1]
You created a HOC, try spread the props:
export const exportWithState = (Component) => (props) => {
return (
<Provider store={store}>
<Component {...props} />
</Provider>
)
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dennis Vash |
