I have a background video in my app, and it loads by default. But I want it not to load in specific pages. Here's my not working solution. It works only when I refresh my page and of course, it's not what I want
import React, { useEffect, useState } from 'react';
import { Route, Switch, Redirect } from 'react-router-dom';
import { routes } from './routes.js';
import './assets/css/style.css';
import Header from './components/global/Header';
import BgVideo from './components/global/BgVideo';
import Menu from './components/global/menu/Menu';
const App = () => {
return (
<div className='app-wrapper'>
{window.location.pathname !== '/portfolio' && <BgVideo />}
<Header />
<Menu />
<Switch>
{
routes.map(item => <Route key={item.id} path={item.pathname} exact component={item.component} />)
}
<Redirect to='/not-found' />
</Switch>
</div>
);
};
export default App;
P.S.: I don't want to hide it with display:none, opacity:0, or something like that. Instead, I want it not to load at all.