Answer the question
In order to leave comments, you need to log in
When to use HOC and when to use a wrapper component?
For example, I have a list of routes like this:
<Switch>
<Route path="/login" component={Login}/>
<Route path="/register" component={Register}/>
<Route path="/recover" component={Recover}/>
</Switch>
<motion.div exit="false">
<Route path="/register" component={Register}/>
</motion.div>
const withMotion = children => (
<motion.div exit="unset">
{children}
</motion.div>
)
<Switch>
[
withMotion(<Route path="/login" component={Login}/>),
withMotion(<Route path="/register" component={Register}/>),
withMotion(<Route path="/recover" component={Recover}/>),
]
</Switch>
const MotionRoute = props => (
<motion.div>
<Route {...props}/>
</motion.div>
)
<Switch>
<MotionRoute path="/login" component={Login}/>
<MotionRoute path="/register" component={Register}/>
<MotionRoute path="/recover" component={Recover}/>
</Switch>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question