Skip to content

Instantly share code, notes, and snippets.

@eddywashere
Forked from gaearon/App.js
Last active February 20, 2020 10:15
Show Gist options
  • Save eddywashere/e13033c0e655ab7cda995f8bc77ce40d to your computer and use it in GitHub Desktop.
Save eddywashere/e13033c0e655ab7cda995f8bc77ce40d to your computer and use it in GitHub Desktop.
Reactstrap App.js Example for create-react-app
import React, { Component } from 'react';
import {
Collapse,
Navbar,
NavbarToggler,
NavbarBrand,
Nav,
NavItem,
NavLink,
Container,
Row,
Col,
Jumbotron,
Button
} from 'reactstrap';
class App extends Component {
constructor(props) {
super(props);
this.toggle = this.toggle.bind(this);
this.state = {
isOpen: false
};
}
toggle() {
this.setState({
isOpen: !this.state.isOpen
});
}
render() {
return (
<div>
<Navbar color="inverse" inverse toggleable>
<NavbarToggler right onClick={this.toggle} />
<NavbarBrand href="/">reactstrap</NavbarBrand>
<Collapse isOpen={this.state.isOpen} navbar>
<Nav className="ml-auto" navbar>
<NavItem>
<NavLink href="/components/">Components</NavLink>
</NavItem>
<NavItem>
<NavLink href="https://github.com/reactstrap/reactstrap">Github</NavLink>
</NavItem>
</Nav>
</Collapse>
</Navbar>
<Jumbotron>
<Container>
<Row>
<Col>
<h1>Welcome to React</h1>
<p>
<Button
tag="a"
color="success"
size="large"
href="http://reactstrap.github.io"
target="_blank"
>
View Reactstrap Docs
</Button>
</p>
</Col>
</Row>
</Container>
</Jumbotron>
</div>
);
}
}
export default App;
@lizzymendivil
Copy link

And also I have this error

Failed to compile.

./src/index.js
Module not found: Can't resolve 'bootstrap/dist/css/bootstrap.min.css' in 'D:\React\my-app2\src'

@MuhammadIdzhar
Copy link

Can we use Col or Container on first line instead of div?

@aishbetu
Copy link

aishbetu commented Sep 4, 2018

To all who're saying bootstrap.css not working. Just import the file at the very first line and it'll work See the example below
import 'bootstrap/dist/css/bootstrap.css';
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';

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