0

I am trying to workout a project on React using the 'create-react-app'. I am making use of Bootstrap in the very same project itself. It seems to work fine except for the 'Bootstrap Grid'. As you can see in the snapshot, the project seems to pick up the custom Bootstrap font & the custom Bootstrap button design, however, it fails to load and pickup the Bootstrap Grid layout.

Project Screenshot

I am using the 'create-react-app' for this project. Following are my files ..

package.json ..

{
  "name": "demo-react-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "loaders.css": "^0.1.2",
    "react": "^16.0.0",
    "react-dom": "^16.0.0",
    "react-loaders": "^2.6.0",
    "react-router": "^4.2.0",
    "react-router-dom": "^4.2.2",
    "react-scripts": "^1.0.14",
    "react-select": "^1.0.0-rc.10",
    "react-slick": "^0.15.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

index.html ..

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="theme-color" content="#000000">
    <!--
      manifest.json provides metadata used when your web app is added to the
      homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
    -->
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json">
    <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
    <!--
      Notice the use of %PUBLIC_URL% in the tags above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.

      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run     build`.
    -->
    <title>Demo React App</title>
    <!-- jQuery for Bootstrap -->
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
    <!-- Bootstrap -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
  </head>
  <body>
    <noscript>
      You need to enable JavaScript to run this app.
    </noscript>
    <div id="root"></div>
    <!--
      This HTML file is a template.
      If you open it directly in the browser, you will see an empty page.

      You can add webfonts, meta tags, or analytics to this file.
      The build step will place the bundled scripts into the <body> tag.

      To begin the development, run `npm start` or `yarn start`.
      To create a production bundle, use `npm run build` or `yarn build`.
    -->
  </body>
</html>

index.js ..

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

ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();

app.js ..

import React, { Component } from 'react';
// import logo from './logo.svg';
import './App.css';

import getRoutes from './routes.js';

import Header from './components/Header/Header.js';
import Footer from './components/Footer/Footer.js';

class App extends Component {
  render() {
    let RouterComponent = (
      <div>
        {getRoutes()}
      </div>
    );

    return (
      // <div className="App">
      //   <header className="App-header">
      //     <img src={logo} className="App-logo" alt="logo" />
      //     <h1 className="App-title">Demo React App</h1>
      //   </header>
      //   <p className="App-intro">
      //     To get started, edit <code>src/App.js</code> and save to reload.
      //   </p>
      // </div>

      <div className="container-fluid">
        <Header />
        <div className="row">
          <div className="col-md-offset-1 col-md-10 col-sm-offset-1 col-sm-10 col-xs-offset-1 col-xs-10">
            <button className='btn btn-default'>Press Me</button>
            {RouterComponent}
          </div>
        </div>
        <Footer />
      </div>
    );
  }
}

export default App;

routes.js ..

import React from 'react';

import MainPage from './views/MainPage/MainPage.js';
import RandomPage from './views/RandomPage/RandomPage.js';
import ContactUsPage from './views/ContactUsPage/ContactUsPage.js';

import { HashRouter,Route } from 'react-router-dom';

export default function getRoutes() {
    return (
        <HashRouter>
            <div>
                <Route exact path='/' component={MainPage}></Route>
                <Route exact path='/RandomPage' component={RandomPage}></Route>
                <Route exact path='/ContactUsPage' component={ContactUsPage}></Route>
            </div>
        </HashRouter>
    );
}

I know there is an alternative to this using 'React Bootstrap', however, I am keen as to why Twitter Bootstrap, itself, is not integrating well with this project. Thanks.

PS : Also, there are no errors or warnings on the console.

1 Answer 1

2

You are using Bootstrap v4 (v4.0.0-beta.2), so the following documentation applies. Specifically, those classes do not exist in v4.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. It works fine when switched to an older version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.