I have a component in which I download and display objects on the list directly from Redux
const roofParts = useSelector((state) => state.roofPart.value);
View
{roofParts.map((o) => {
return <RoofPart key={o.id} roofPart={o} points={o.points} />;
})}
In a rendered component, I want to use dispatch to be able to perform change operations on this particular object directly in redux
function RoofPart({ roofPart, points }) {
const dispatch = useDispatch(); // Error
return (
<Container>
</Container>
);
}
function areEqual(prevProps, nextProps) {
if (prevProps.points.length === nextProps.points.length) {
return true;
} else {
return false;
}
}
export default React.memo(RoofPart, areEqual);
Just calling the line with const dispatch = useDispatch(); causes the following error
useReduxContext.js:24 Uncaught Error: could not find react-redux context value; please ensure the component is wrapped in a <Provider>
Is it not possible to use Redux in a dynamic component or what is the reason?