Application setup

The React router doesn't look the same as other JS routers. It uses the JSX syntax that makes it different to other routers. First we will create a sample app without using the npm package for a better understanding of the router concept.

Follow these instructions to do the setup:

  1. Copy the Chapter 2 directory structure and files into Chapter 7.
  2. Delete the existing HTML files and create a new index.html.
  3. Copy this boilerplate code in your HTML:
            <!doctype html>
            <html lang="en">
                <head>
                    <meta charset="utf-8">
                    <title>React Router - Sample application with 
                    bootstrap</title>
                    <link rel="stylesheet" href="css/bootstrap.min.css">
                    <link rel="stylesheet" href="css/font-awesome.min.css">
                    <link rel="stylesheet" href="css/custom.css">
                    <script type="text/javascript" src="js/react.js"></script>
                    <script type="text/javascript" src="js/react-dom.min.js">
                    </script>
                    <script src="js/browser.min.js"></script>
                    <script src="js/jquery-1.10.2.min.js"></script>
                    <script src="js/bootstrap.min.js"></script>
                    <script src="https://unpkg.com/react-router/umd/
                    ReactRouter.min.js"></script>
                    <script src="components/bootstrap-navbar.js" type=
                    "text/babel"></script>
                    <script src="components/sidebar.js" type="text/babel">
                    </script>
                    <script src="components/sidebar.js" type="text/babel">
                    </script>
                </head>
                <body>
                    <div id="nav"></div>
                    <div class="container">
                        <h1>Welcome to EIS</h1>
                        <hr>
                        <div class="row">
                            <div class="col-sm-3" id="sidebar">
                                <!--left col-->
                            </div>
                            <!--/col-3-->
                            <div class="col-sm-9 profile-desc" id="main">
                            </div>
                            <!--/col-9-->
                        </div>
                    </div>
                    <!--/row-->
                </body>
            </html> 
    
  4. Open the index.html in the browser. Make sure that the output does not show any errors in the console.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset