remix-run / react-router

Declarative routing for React
https://reactrouter.com
MIT License
53.13k stars 10.31k forks source link

Simple routing seems like not working for me #1036

Closed hung-phan closed 9 years ago

hung-phan commented 9 years ago

I run into this trouble today with react: 0.13.1, and react-router: 0.13.2. It can only render the DefaultRoute but not the 'test' Route. Did I do something wrong with this one?. I stuck with it for one hour and still counting.

'use strict';

import React from 'react/addons';
import {Route, RouteHandler, DefaultRoute, HashLocation, run} from 'react-router';
import MainPage from './quiz/main-page';
import QuizDetails from './quiz/quiz-details';
import ResultPage from './quiz/result-page';

class Wrapper extends React.Component {
  render() {
    return (
      <RouteHandler />
    );
  }
}

class Test1 extends React.Component {
  render() {
    return (
      <div>
        <h1>Test 1</h1>
      </div>
    );
  }
}

class Test2 extends React.Component {
  render() {
    return (
      <div>
        <h1>Test 2</h1>
      </div>
    );
  }
}

const routingComponent = document.getElementById('routing-component');

if (routingComponent) {
  let routes =
    <Route name='app' path='/' handler={Wrapper}>
      <Route name='test' handle={Test1} />
      <DefaultRoute handler={Test2} />
    </Route>;

  run(routes, HashLocation, (Handler) => {
    React.render(<Handler />, routingComponent);
  });
}
hung-phan commented 9 years ago

A typo, of course. handle must be handler