Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Cannot read property 'length' of undefined #623

Closed
sam3k opened this issue Dec 17, 2014 · 6 comments
Closed

Uncaught TypeError: Cannot read property 'length' of undefined #623

sam3k opened this issue Dec 17, 2014 · 6 comments

Comments

@sam3k
Copy link

sam3k commented Dec 17, 2014

I get that error and points to line 343: var currentRoute = state.routes[state.routes.length-1];

Here is my code:

var React = require('react');

// Routing
var Router = require('react-router');
var Route = Router.Route;

// Load Pages
var AccountingPage = require('./pages/accounting/home.js');

var App = React.createClass({

    getInitialState: function(){
        return {
            data: pageData
        }
    },

    render: function(){
        return (
            <div>
                <Header data={this.state.data} />
                <RouteHandler/>
                <Footer/>
            </div>
            )
    }

});

var routes = (
    <Route name="app" path="/accounting" handler={App}>
        <Route name="acct" path="/acct" handler={AccountingPage} />
    </Route>
);

Router.run(routes, function (Handler) {
    console.log('hit a react route');
    React.render(<Handler/>, document.getElementById('App') );
});

Any idea what I'm missing?

@gaearon
Copy link
Contributor

gaearon commented Dec 17, 2014

Could this be a bug introduced in 0c3c75d?
Can you try with 0.11.4?

@gaearon
Copy link
Contributor

gaearon commented Dec 17, 2014

cc @vladimir-vg

gaearon referenced this issue Dec 17, 2014
[fixed] Now execute willTransition* hooks even if only query part was changed
@sam3k
Copy link
Author

sam3k commented Dec 17, 2014

@gaearon you're right; 0.11.4 works!

@mjackson
Copy link
Member

@sam3k I'm guessing that you're running into this issue when you redirect from the willTransitionTo hook on the initial page load. Is that right?

I'm looking into this now. Should have a fix out shortly.

@mjackson
Copy link
Member

The fix is available on npm in version 0.11.6

Thanks for the bug report @sam3k !

@sam3k
Copy link
Author

sam3k commented Dec 17, 2014

Good stuff! Thanks for the quick fix @mjackson

@lock lock bot locked as resolved and limited conversation to collaborators Jan 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants