Instantly share code, notes, and snippets.

View index.js
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();
View App.js
import React from 'react';
const App = () => <h1>I am the App.</h1>;
export default App;
View Home.js
import React from 'react';
const Home = () => <h1>I am the home page!</h1>;
export default Home;
View App.js
import React from 'react';
import { BrowserRouter, Switch, Route } from 'react-router-dom';
import Landing from './components/Landing';
const App = () => (
<BrowserRouter>
<Switch>
<Route exact path="/" component={Landing} />
</Switch>
</BrowserRouter>
View App.js
import React from 'react';
import { BrowserRouter, Switch, Route } from 'react-router-dom';
import Landing from './components/Landing';
import Home from './components/Home';
import Profile from './components/Profile';
import PageNotFound from './NotFound';
const App = () => (
<BrowserRouter>
<Switch>
View firebase.js
import 'firebase/firestore';
import * as firebase from 'firebase';
const {
REACT_APP_FB_API_KEY,
REACT_APP_AUTH_DOMAIN,
REACT_APP_FB_DB_URL,
REACT_APP_FB_PROJ_ID,
REACT_APP_FB_STORAGE_BUCKET,
REACT_APP_MESSAGING_SENDER_ID,
View App.js
class App extends React.Component {
state = { signedIn: undefined };
componentDidMount() {
auth.onAuthStateChanged((user) => {
if (user) {
this.setState({
signedIn: true,
});
} else {
View App.js
class App extends React.Component {
state = { signedIn: undefined };
render() {
return (
<BrowserRouter>
<Switch>
<Route exact path="/" component={Landing} />
<Route exact path="/home" component={Home} />
<Route exact path="/profile" component={Profile} />
View App.js
componentDidMount() {
auth.onAuthStateChanged((user) => {
if (user) {
this.setState({
signedIn: true,
});
} else {
this.setState({
signedIn: false,
});
View App.js
import React from 'react';
import { BrowserRouter, Switch, Route } from 'react-router-dom';
import auth from './api/firebase';
import Landing from './components/Landing';
import Home from './components/Home';
import Profile from './components/Profile';
import PageNotFound from './NotFound';
class App extends React.Component {
state = { signedIn: undefined };