mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-25 17:53:44 +02:00
use children in routes instead of component prop
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
import React, { useRef } from 'react';
|
||||
import React from 'react';
|
||||
import { Route } from 'react-router';
|
||||
import { SwitchTransition } from 'react-transition-group';
|
||||
import Fade from '@/components/elements/Fade';
|
||||
import styled from 'styled-components/macro';
|
||||
import tw from 'twin.macro';
|
||||
import v4 from 'uuid/v4';
|
||||
|
||||
const StyledSwitchTransition = styled(SwitchTransition)`
|
||||
${tw`relative`};
|
||||
@@ -15,13 +14,11 @@ const StyledSwitchTransition = styled(SwitchTransition)`
|
||||
`;
|
||||
|
||||
const TransitionRouter: React.FC = ({ children }) => {
|
||||
const uuid = useRef(v4()).current;
|
||||
|
||||
return (
|
||||
<Route
|
||||
render={({ location }) => (
|
||||
<StyledSwitchTransition>
|
||||
<Fade timeout={150} key={location.key || uuid} in appear unmountOnExit>
|
||||
<Fade timeout={150} key={location.pathname + location.search} in appear unmountOnExit>
|
||||
<section>
|
||||
{children}
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user