Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Last active Dec 12, 2020
Embed
What would you like to do?
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

productioncoder commented Dec 12, 2020

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