Coder Social home page Coder Social logo

Comments (4)

srconklin avatar srconklin commented on July 25, 2024

In addition to the above question.. would there be a way in React-mini-router to do something that React Router does for "willTransitionTo"
https://github.com/rackt/react-router/blob/master/docs/api/components/RouteHandler.md

I am need of an authentication check on each request that redirects to a login page if the user is not logged in or times out etc...

from react-mini-router.

larrymyers avatar larrymyers commented on July 25, 2024

I have some ideas for your use case. will get you a detailed response once I'm done traveling for the holidays this week.

On Dec 29, 2014, at 11:05 AM, Scott Conklin [email protected] wrote:

In addition to the above question.. would there be a way in React-mini-router to do something that React Router does for "willTransitionTo"
https://github.com/rackt/react-router/blob/master/docs/api/components/RouteHandler.md

I am need of an authentication check on each request that redirects to a login page if the user is not logged in or times out etc...


Reply to this email directly or view it on GitHub.

from react-mini-router.

larrymyers avatar larrymyers commented on July 25, 2024

The RouterMixin was designed to be used at the top level root component of an app. You can add your auth check in the root component's render method, and do conditional rendering there.

I'd have to think through pre/post callbacks for route handlers to see if it's possible to augment the existing v1.0 API without requiring a major version bump.

Code example:

var MyApp = React.createClass({

    mixins: [RouterMixin],

    render: function() {
        if (mustLogin) {
            return this.renderLogin();
        } else {
            return <div>{this.renderCurrentRoute()}</div>;
        }
    }

});

from react-mini-router.

srconklin avatar srconklin commented on July 25, 2024

thanks.. i came to the same conclusion after playing around with it for a while.

from react-mini-router.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.