I am sure that this is relate to me not totally understanding how React Spring works or maybe HOCs.
I am trying to create a HOC for React that adds a React Spring animation (slides the child component in from the left)
const SlideLeft = WrappedComponent => {
const [props] = useSpring({
translateX: "0",
from: { translateX: "1000vw" }
});
return (
<animated.div style={props}>
<WrappedComponent />
</animated.div>
);
};
And then later on, in another component, I have this:
<SlideLeft>
<Categories />
</SlideLeft>
I would think this would work, but instead I am getting the error:
TypeError: arr[Symbol.iterator] is not a function
I found this page which suggested changing it to just const props:
https://github.com/react-spring/react-spring/issues/616
However, when I do that I get the error:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
Check the render method of `SlideLeft`.
So I'm not quite sure how to get a HOC working with React Spring.
Any information would be illuminating.