I used react-router-dom and react-spring's useTransitions, animated for page transitions, but transition animation works well, but there are some bugs. I think I can solve it with CSS, but I do not know what to do. If you know how to solve it, I would be very thankful if you help me.
I tried page transitions using react-router-dom, react-spring, useTransitions, animated, __RouterContext
No error messages. it's some bugs
It rises from bottom to top. I just want to be in the center and give the opacity effect when moving the page.
function App() {
const { location } = useContext(__RouterContext);
const transitions = useTransition(location, location => location.pathname, {
from: { opacity: 0 },
enter: { opacity: 1 },
leave: { opacity: 0 }
});
return (
<React.Fragment>
<Navbar />
{transitions.map(({ item, props, key }) => (
<animated.div key={key} style={props}>
<Switch location={item}>
<Route exact path="/" component={Home} />
<Route exact path="/profile" component={Profile} />
<Route exact path="/about" component={About} />
<Route exact path="/project" component={Project} />
<Route exact path="/contact" component={Contact} />
</Switch>
</animated.div>
))}
</React.Fragment>
);
}
export default App;