Resolve CRA Build blank page -
Resolve CRA Build blank page
by on on react

Resolve CRA Build blank page

How to solve create react app build blank page.

React Js is a great framework for build beautiful sleek and fast single page applications. Once anyone is done build an app the next thing is to deploy it to the Cpanel or any hosting channel which support deployment. But one issue you may face is the problem of having this blank screen after you build your react js application which totally upsets you, below are the procedures you can use to resolve it.

These are Two types of solution


import React from "react";
import { withRouter } from "react-router-dom";
const FOLDER_NAME = "/portfolio/";
function Login() {
  return <div>Login</div>;
}
function App() {
  const { pathname } = window.location;
  // Get the pathname
  console.log(pathname);
  const SwitchRoutes = (pathname) => {
    switch with the pathname
    switch (pathname) {
      case `${FOLDER_NAME}`:
        return <div>Home</div>;
      case `${FOLDER_NAME}login`:
        return <Login />;
      default:
        return <div>No route</div>;
    }
  };
 return <>{SwitchRoutes(pathname)}</>;
} export default App;

OR  you are using react router dom


<Router basename="/portfolio/">
      <Allroutes />
</Router>