npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-router-v4-transition

v1.0.0

Published

[![Build Status](https://travis-ci.org/aboeglin/react-router-v4-transition.png?branch=master)](https://travis-ci.org/aboeglin/react-router-v4-transition) [![Coverage Status](https://coveralls.io/repos/github/aboeglin/react-router-v4-transition/badge.svg?b

Downloads

6

Readme

React Router Transition

Build Status Coverage Status npm version

Transitions for React Router v4. The API is composed of a component, TransitionSwitch, that should be used as the Switch component from react-router v4 to switch from a route to another one with a transition. That transition can be any action you need to do between routes, like animation, or fetching data.

API Description

1) The component:

<TransitionSwitch parallel={false}>
    <Route exact path="/">
        <Transition>home path</Transition>
    </Route>
    <Route path="/otherPath">
        <Transition>other path</Transition>
    </Route>
    <Route path="/">
        <Transition>other home</Transition>
    </Route>
    <Route path="/anotherPath">
        <Transition>another path</Transition>
    </Route>
</TransitionSwitch>

TransitionSwitch allows you to perform transitions on route change. Given its name, it works like the router v4 Switch. It means that only one route will be visible at all times. Except if parallel is set to true, which means that the entering transition won't wait for the leaving transition to be finished. NB: parallel may be renamed in the future.

2) The transitions:

Like a switch, the children must be Route elements. The children of these route elements will be given hooks to perform the transition. These hooks are :

class Transition extends React.Component {
    
    componentWillAppear(callback) {
        //do something when the component will appear
        
        callback();
    }
    
    componentDidAppear() {
        //do something when the component appeared
    }
    
    componentWillEnter(callback) {
        //do something when the component will enter
        
        callback();
    }
    
    componentDidEnter() {
        //do something when the component entered
    }
    
    componentWillLeave(callback) {
        //do something when the component will leave
                
        callback();
    }
    
    componentDidLeave() {
        //do something when the component has left    
    }
    
}

The callbacks must be called after the transition is complete, in the case of animation, a good place is in the callback provided by the animation library. The interface is very much the same as react-trasition-group v1. This means that componentWillAppear is called for the first time when the TransitionSwitch is mounted.

Sample App

In case you want to quickly try it, there's a webpack setup and very rough sample app. In order to build it you should run :

npm run build:example
npm run start:server

The app will be running at localhost:8080, the build command watches for changes in case you want to play with it, the sources are located in src/example.