React onClick and preventDefault() link refresh/redirect?

前端 未结 13 771
生来不讨喜
生来不讨喜 2020-11-30 06:04

I\'m rendering a link with react:

render: ->
  `upvote`

Then, above I hav

13条回答
  •  渐次进展
    2020-11-30 06:49

    If you are using React Router, I'd suggest looking into the react-router-bootstrap library which has a handy component LinkContainer. This component prevents default page reload so you don't have to deal with the event.

    In your case it could look something like:

    import { LinkContainer } from 'react-router-bootstrap';
    
    
        upvote
    
    

提交回复
热议问题