how to link to a different component in reactjs without react router

JavaScript
const showComponent = (route, component) => {
  return window.location.pathname === route ? component : null
}
Source

Also in JavaScript: