404 page in REACT

前端 未结 4 1660
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-01 23:48

I created the component NotFound and it works fine when I go to a page that doesn\'t exist. But the same page it\'s appearing in all my pages, not only the one

4条回答
  •  离开以前
    2021-01-01 23:59

    Try This:

    import React from "react";
    import { Redirect, Route, Switch, BrowserRouter } from 'react-router-dom';
    import HomePage from './pages/HomePage.jsx';
    import NotFoundPage from './NotFoundPage.jsx';
    class App extends React.Component {
        render(){
            return(
                
                    
                        
                        
                    
                
            )
        }
    }
       
    export default App;
    
    

提交回复
热议问题