4

i develop my project with react-router.

below is my code.

const App2 = React.createClass({
    render() {
        return (
            <div>
                <Link to="index">index</Link>
                <Link to="favorite">favorite</Link>
                <Link to="myPage">myPage</Link>
                {this.props.children}
            </div>
        )
    }
});

var app = ReactDOM.render (
    <Router history={browserHistory}>
        <Route path="/" component={App2}>
            <Route path="index" component={PhotoFeedWrapper}/>
            <Route path="favorite" component={FavoriteWrapper}/>
            <Route path="myPage" component={MyPageWrapper}/>
        </Route>
    </Router>,
    document.getElementById('app')
);

i think my code right. but, this render empty like below.

<div id="app"><!-- react-empty: 1 --></div>

there is no script error.

What did I do wrong?

5
  • 1
    How are you accessing it? Using http://localhost/index? Also, can you post your other components to see if they are correct? Commented Jul 7, 2016 at 1:07
  • @WilliamMartins No, i accessing it http://localhost:8080/contextPath/index. i don't use it on node. i use it with spring and UMD build. so, i use like that. other component is correct Commented Jul 7, 2016 at 1:14
  • It is strange, are your links being rendered? Commented Jul 7, 2016 at 1:22
  • @WilliamMartins thank you for your help. i didn't know that uri must match. Commented Jul 7, 2016 at 1:33
  • Oh, did it help? :D Commented Jul 7, 2016 at 1:38

1 Answer 1

1

Link component currently only support absolute path. You have to change to:

<Link to="/index">index</Link>
<Link to="/favorite">favorite</Link>
<Link to="/myPage">myPage</Link>
Sign up to request clarification or add additional context in comments.

1 Comment

I saw your Link set up then I immediately posted this. Then I realize this doesn't answer your original question. But it does fix one other error in your code. :P

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.