react-router dynamic segments crash when accessed

后端 未结 2 736
慢半拍i
慢半拍i 2020-12-13 08:52

I have a route configuration that looks like this (showing only the parts that I think may be relevant):

var React = require(\'react\');

var Router = require         


        
2条回答
  •  我在风中等你
    2020-12-13 09:23

    I am not encountering the error that you're seeing. It seems like your code is all right, so it's probably something that you didn't paste.

    giving the information, I've build a quick project according to your spec and here's my setup

    'use strict';
    
    var React           = require('react'),
        Router          = require('react-router'),
        AppHandler      = require('./pages/app.js'),
        HomeHandler     = require('./pages/home.js'),
        SettingsHandler = require('./pages/setting.js'),
        NotFoundHandler = require('./pages/not-found.js'),
    
        Route           = Router.Route,
        NotFoundRoute   = Router.NotFoundRoute,
        DefaultRoute    = Router.DefaultRoute,
        Routes;
    
    Routes = (
        /* jshint ignore:start */
        
            
            
            
            
        
        /* jshint ignore:end */
    );
    
    Router.run(Routes, Router.HistoryLocation, function (Handler, state) {
        React.render(, document.body);
    });
    

    I'm skipping the home and not found since those are not the problem, here's my setup in settings.js

    'use strict';
    var React = require('react')
        Router = require('react-router');
    
    var Setting = React.createClass({
    
        mixins: [Router.State],
        componentDidMount: function() {
            //console.log(this.getParams());
        },
    
        render: function() {
            /* jshint ignore:start */
            console.log(this.getParams());
            return (
                
    this is setting
    ); /* jshint ignore:end */ } }); module.exports = Setting;

    hope these will help

提交回复
热议问题