Skip to content
This repository was archived by the owner on Sep 20, 2021. It is now read-only.
This repository was archived by the owner on Sep 20, 2021. It is now read-only.

[Request] Add integration example with Reach Router #61

Description

@Oba-One

Hi! @drcmda I was wondering if you have examples with Reach Router. Here's what I have so far, appreciate the help!

import React, { useState } from 'react';
import { Router, Location } from '@reach/router';
import { useTransition, animated } from 'react-spring';
import { Container } from '../global';
import styled from 'styled-components';

const AnimatedContainer = styled(animated(Container))``;

const AnimatedRouter = ({ children }) => {
	const [index, set] = useState(0);
	const transitions = useTransition(index, p => p, {
		from: { opacity: 0, transform: 'translate3d(100%,0,0)' },
		enter: { opacity: 1, transform: 'translate3d(0%,0,0)' },
		leave: { opacity: 0, transform: 'translate3d(-50%,0,0)' },
	});

	return (
		<Location>
			{({ location }) => (
				<AnimatedContainer key={location.key}>
					<Router location={location}>{children}</Router>
				</AnimatedContainer>
			)}
		</Location>
	);
};

export default AnimatedRouter;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions