Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Last active December 12, 2020 08:43
Show Gist options
  • Save productioncoder/cd7e770eb520e8171d79b27531d5772a to your computer and use it in GitHub Desktop.
Save productioncoder/cd7e770eb520e8171d79b27531d5772a to your computer and use it in GitHub Desktop.
Navigating between Home and Watch component
import React, {Component} from 'react';
import {Home} from './containers/Home/Home';
import {AppLayout} from './components/AppLayout/AppLayout';
import {Route, Switch} from 'react-router-dom';
import {Watch} from './containers/Watch/Watch';
class App extends Component {
render() {
return (
<AppLayout>
<Switch>
<Route path="/watch" component={Watch}/>
<Route path="/" component={Home}/>
</Switch>
</AppLayout>
);
}
}
export default App;
@nisaji
Copy link

nisaji commented Dec 12, 2020

It sems missing of importing Watch.
This below code seems right.

import React, { Component } from 'react';
import {Home} from './containers/Home/Home';
import {Watch} from './containers/Watch/Watch';
import { AppLayout } from './components/AppLayout/AppLayout';
import {Route, Switch} from 'react-router-dom'

class App extends Component {
  render() {
    return (
        <AppLayout>
          <Switch>
            <Route path='/watch' component={Watch}/>
            <Route path='/' component={Home}/>
          </Switch>
        </AppLayout>     
    );
  }
}

export default App;

@productioncoder
Copy link
Author

Yes, thanks for bringing this up. I updated the gist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment