在文本中的超链接反应

时间:2018-07-25 10:58:11

标签: reactjs

如何在我尝试过的文本上建立链接,请帮助我做错了

  

当我单击立即加入文本时,注册是组件,唯一的路径更改   例如注册/

<BrowserRouter>
     <Link to="/Signup"> Join now</Link>
</BrowserRouter>
  

错误

index.js:2178 Warning: validateDOMNesting(...): <a> cannot appear as a descendant of <a>.
    in a (created by Link)
    in Link (at Login.js:205)
    in Router (created by BrowserRouter)
    in BrowserRouter (at Login.js:203)
    in a (at Login.js:123)
    in MyLink (created by WithStyles(MyLink))
    in WithStyles(MyLink) (at Login.js:200)
    in p (created by Typography)
    in Typography (created by WithStyles(Typography))
    in WithStyles(Typography) (at Login.js:197)
    in div (created by Paper)
    in Paper (created by WithStyles(Paper))
    in WithStyles(Paper) (created by Card)
    in Card (created by WithStyles(Card))
    in WithStyles(Card) (at Login.js:166)
    in div (at Login.js:164)
    in Login (created by WithStyles(Login))
    in WithStyles(Login) (at App.js:35)
    in div (at App.js:33)
    in App (created by WithStyles(App))
    in WithStyles(App) (at index.js:9)

1 个答案:

答案 0 :(得分:0)

import React from 'react';
import ReactDOM from 'react-dom';
import {BrowserRouter as Router, Route, NavLink} from 'react-router-dom';

ReactDOM.render(
<Router>
  <div>
    <ul>
      {/*You can add more links here*/}
      <li><NavLink to='/Signup'>Join Now</NavLink></li>
    </ul>

    <hr/>

    <Route path='/SignUp' component={ComponentName} />
  </div>
)