S
S
symblight2017-02-20 19:02:52
JavaScript
symblight, 2017-02-20 19:02:52

How to properly implement url in ReactJS?

How can I work in React with Url for example http://mysite.me/{nickname} - the address of the link to the Account component. The problem is nickname, it changes. Similarly, for example mysite.me/post?id.... url is dynamic.
I implemented the transition to components through React-router, but I set the address in advance.
Nav.jsx

<div className="el_menu">
      <Link to="/account" ><h4>Account</h4></Link>
   </div>

App.jsx
<Router history={browserHistory}>
            <Route path="/" component={Main}>
                <IndexRoute component={Home}/>
                <Route path="account" component={Account}/>
                <Route path="post" component={Post}/>
            </Route>
        </Router>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Frozen Coder, 2017-02-20
@frozen_coder

:nickname - path parameter. Will lie in props. this.props.params.nickname
https://github.com/reactjs/react-router-tutorial/t...
God bless you and read the documentation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question