First of all I'm new to react and coding in general and have become stuck.
I'm trying to build components that I can favorite and render on a separate page.
I'm using redux to store the state of the components whether it has been favorited or not.
The problem I'm having is in my HOC (isFavorited) I can not access redux useSelector
const isFavorited = (Component) => {
const url = "URL"; //This will check wheater im on the page that I always want it rendering
const count = useSelector((state) => state.favourite.value); //Need to check weather the render state
console.log(Component);
if (count === 1 || url === "url") {
return (props) => <Component {...props} />;
}
return () => <span>No render</span>;
};
const CardLong = isFavorited((props) => {
const count = useSelector((state) => state.favourite.value);
const dispatch = useDispatch();
return (
**MY JSX IS HERE REMOVED FOR EASY READING**
);
});
export default CardLong;
