qiqiboy / react-animated-router

Dynamic transitions with react-router(v6) and react-transition-group
58 stars 17 forks source link

1 #8

Open wenchengshen opened 2 years ago

wenchengshen commented 2 years ago

如何设置部分的路由不需要有动画效果呢

qiqiboy commented 2 years ago

需要将不想使用动画的子路由拆解到组件内部就可以了:

<AnimatedRoutes>
      <Route path="/" element={<App />} />
     <Route path="/sub" element={<Sub />}>
            <Route path="no-animation" element={<NoAnimation />} />
    </Route>
</AnimatedRoute>

变更为

<AnimatedRoutes>
      <Route path="/" element={<App />} />
     <Route path="/sub" element={<Sub />} />
</AnimatedRoute>

// Sub
function Sub() {
    return <Routes>
   <Route path="no-animation" element={<NoAnimation />} />
</Routes>
}