Error with hashrouter and browser router. witch gh-pages

Asked
Active3 hr before
Viewed126 times

9 Answers

hashrouterbrowserwitchpagesroutererror
90%

I'm using BrowserRouter to deploy the page in GH-PAGES, and it shows me the blank page. But when I use hashRouter, it does. But my route with router hash is username.github.io / # / ... the fact is that I am using fullpage.js and every time I scroll it changes the url to #About, #Project, etc. etc. And if I use a hash router, it doesn't jump to #About, but instead it redirects me to / About, which is another page. I would like to publish my site using browser router. what would be the solution?, Does the stock market fall faster than it rises? , What happens if you use a battery to charge up a capacitor fully, and then disconnect the battery, where does the charge 'go'?

 Pretag team - issue, fix, solve, resolve
88%

const HashRouter = ReactRouterDOM.HashRouter;
const Route = ReactRouterDOM.Route;
const Link = ReactRouterDOM.Link;
const Switch = ReactRouterDOM.Switch;

const Players = () => (
  <div>
    <h5>Players</h5>
    <Switch>
      <Route path="/players/joe" render={() => <div>Joe</div>} />
      <Route path="/players/emily" render={() => <div>Emily</div>} />
    </Switch>
  </div>
);

ReactDOM.render(
  <HashRouter>
    <div>
      <h5>Navigation</h5>
      <ul>
        <li><Link to="/players">Players</Link></li>
        <li><Link to="/players/joe">Players - Joe</Link></li>
        <li><Link to="/players/emily">Players - Emily</Link></li>
        <li><Link to="/about">About</Link></li>
      </ul>
      <Switch>
        <Route path="/players" component={Players} />
        <Route path="/about" render={() => <div>About Page</div>} />
      </Switch>
    </div>
  </HashRouter>,
  document.getElementById("root")
);
load more v
72%

The easiest way to reload the entire page is to just window.location.reload().,Can you be more specific about what you need, @pdeva? For example, when you say "reload current route" do you want all onEnter hooks to fire? Or do you just want to re-render?,If you are using react-router you can use history.go(n). if n=0 then reload current page.

// I just wanted to reload a /messages page
history.pushState(null, '/');
history.pushState(null, '/messages');
load more v
65%

By using pushstate we can change the URL and not have the browser request the page from the server and without needing to use a hash fragment.,By using a hash fragment the server never needs to know about any application URL, it will only ever get asked for the root page and it will only ever return the root page.,This changes the URL programmatically using the HTML5 History API in such a way that the browser doesn’t make a request to the server for the new URL.

RouterModule.forRoot(routes, {
   useHash: true
})
load more v
75%

In our example above we are just showing the HomeComponent but normally we might show an error 404 page.,Routes & RouterModule,RouterOutlet Directive

<app-header></app-header>
<div class="m-t-1">
   <app-search></app-search>
</div>
load more v
40%

Wrapper (Router) – <BrowserRouter> and <HashRouter>,For the first single-page app I created in 2020, I decided to use the React Router. Wow! Creating the app was 1000 times easier than earlier, and no headaches 🤗 (That’s why 800k+ repositories use this router).,The first thing I did was to learn how to use the React Router. For this, I used a learning-by-doing method. In this article, I’ll explain how I created a simple app using React Routing.

Getting Started

/n

In this guide, we will be using the latest version (5.1.2) of the react-router-dom library, which includes DOM bindings for the react-router library. So, we can use it in our web app.

react - router
load more v
22%

 Pretag team - issue, fix, solve, resolve
60%

https://github.com/Azure/azure-event-hubs-for-kafka, Azure Event Hubs With Kafka ,So once you have done that, you can simply grab the code from this repo : https://github.com/Azure/azure-event-hubs-for-kafka/tree/master/quickstart/dotnet

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <extensions>
    <add assembly="NLog.Gelf" />
  </extensions>

  <targets>
    <target name="console" xsi:type="Console" layout="${date:format=dd/MM/yyyy HH\:mm\:ss.fff} | ${level:uppercase=true} | ${message}${exception:format=ToString}" />
    <target name="Gelf" type="GelfHttp" serverUrl="http://localhost:12201/gelf" facility="sachas app"/>
  </targets>

  <rules>
    <logger name="*" minLevel="Trace" appendTo="Gelf, console"/>
  </rules>
</nlog>

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <extensions>
    <add assembly="NLog.Gelf" />
  </extensions>

  <targets>
    <target name="console" xsi:type="Console" layout="${date:format=dd/MM/yyyy HH\:mm\:ss.fff} | ${level:uppercase=true} | ${message}${exception:format=ToString}" />
    <target name="Gelf" type="GelfHttp" serverUrl="http://localhost:12201/gelf" facility="sachas app"/>
  </targets>

  <rules>
    <logger name="*" minLevel="Trace" appendTo="Gelf, console"/>
  </rules>
</nlog>
load more v
48%

If you are on a personal connection, like at home, you can run an anti-virus scan on your device to make sure it is not infected with malware.,If you are at an office or shared network, you can ask the network administrator to run a scan across the network looking for misconfigured or infected devices.,Completing the CAPTCHA proves you are a human and gives you temporary access to the web property.

 Pretag team - issue, fix, solve, resolve

Other "hashrouter-browser" queries related to "Error with hashrouter and browser router. witch gh-pages"