DEV Community

Hemant Govekar
Hemant Govekar

Posted on

2 2

React-Router - Video#2

The below code base is a supporting article for my youtube reactjs series. Link.
My plan for creating the entire video series is listed at the end of this article.

Webpack.config.js

const path = require('path');

module.exports = {
  entry: './src/index.js',
  output: {
    path: path.resolve('dist'),
    filename: 'main.js',
  },
  module: {
    rules: [
      {
        test: /\.js?$/,
        loader: 'babel-loader',
        exclude: /node_modules/,
      },
      {
        test: /\.css$/i,
        use: ['style-loader', 'css-loader'],
      },
      {
        test: /\.svg$/i,
        use: [{loader: 'file-loader', options: {esModule: false}}],
      },
    ],
  },
};

Enter fullscreen mode Exit fullscreen mode

App.js

import React from 'react';
import {BrowserRouter as Router, Switch, Route, Link} from 'react-router-dom';
import Home from './components/Home';
import Users from './components/Users';

const App = () => {
  return (
    <Router>
      <div>
        <nav>
          <ul>
            <li>
              <Link to="/home">Home</Link>
            </li>

            <li>
              <Link to="/users">Users</Link>
            </li>
          </ul>
        </nav>
      </div>

      <Switch>
        <Route path="/home" component={Home}></Route>
        <Route path="/users" component={Users}></Route>
      </Switch>
    </Router>
  );
};

export default App;
Enter fullscreen mode Exit fullscreen mode

index.js


import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

ReactDOM.render(<App />, document.getElementById('root'));
Enter fullscreen mode Exit fullscreen mode

I am planning to create a video tutorial series for ReactJs. Would you be interested ?? Please comment and let me know.

Following would be the plan

  • Create a basic app with webpack babel. (Done) Link
  • Add routing and get a simple react page ready.(Done) Link
  • Adding Sass for css
  • UseFetch Hooks
  • Call jsonplaceholder API in the application.
  • Input form Validations in react application.
  • Firebase application for CRUD.
  • Tomcat deployment for ReactJs.
  • Advance Topics....

Subscribe my channel to watch the videos :-)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more