react-router: Why the preference for browserHistory over hashHistory?

后端 未结 3 964
青春惊慌失措
青春惊慌失措 2021-02-02 01:28

I\'m relatively new to React; apologies if this is a really naive question.

What are the technical advantages to browserHistory that make it prefer

3条回答
  •  耶瑟儿~
    2021-02-02 02:21

    One reason browserHistory is preferred over hashHistory is that it is better for deployment and production. hashHistory "works" by adding a unique key at the end of the url and creates a "history" for this by using these keys to keep track of your current session.

    browserHistory looks much cleaner without the #, but in order to get this set up, you need to configure your server such that it can handle the URLs you intend to provide it.

    Hope that helps!

提交回复
热议问题