In reference to the unresolved question (as a final conclusion)
This is one way of doing what you described (note there are other ways of handling layouts directly in your React Components). In order to keep the example simple, the other components (
etc.) are created as purely functional components with no properties or state but it would be trivial to put each one in its own file as a proper React component. The example below is complete and will run.
import React, { Component } from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
class App extends Component {
render() {
const Header = () => My header
;
const Footer = () => My footer
;
const Login = () => Login Component
;
const Home = () => Home Page
;
const List = () => List Page
;
const Settings = () => Settings Page
;
const PageNotFound = () => Uh oh, not found!
;
const RouteWithLayout = ({ component, ...rest }) => {
return (
React.createElement(component) } />
);
};
return (
);
}
}
export default App;
This will do the following, which is hopefully what is now described in your question:
/login
has no header or footer./
, /list
, and /settings
all have the header and footer.PageNotFound
component, with no header or footer.