React Router Basic & Implementation On React App

index.jsimport React from 'react';import ReactDOM from 'react-dom';import {createStore, applyMiddleware, compose} from 'redux'import thunk from 'redux-thunk'import { Provider } from 'react-redux'import {BrowserRouter as Router} from 'react-router-dom'import playerReducer from './reducers/playerReducer'import App from './App';const composeEnchancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;const store = createStore(playerReducer,composeEnchancers(applyMiddleware(thunk)))ReactDOM.render(<Provider store={store}>
// Any component that I wrapped in provider will have access to our Redux Store.
I must call store in provider as I call in variable
<Router> <App /></Router></Provider>,document.getElementById('root'));render () {*return* (<div><Switch>
<Route path='/players/new'
<Route path='/players/new' component={PlayerInput}
<Route path='/players' render={() => Accounts players={this.props.players}
<Route path='/players/new' component={PlayerInput}<Route path='/players' render={() => Accounts players={this.props.players}
<Route  exact path='/players' render={() => Accounts players={this.props.players}
<Route path=’/players/:id’
<Route path='/players/:id' render={(routerProps) =>< Player {...routerProps}  players={this.props.players}/> }/>

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Soner Mezgitci

Soner Mezgitci

31 Followers

Software Engineer | Ruby on Rails | JavaScript | HTML5 | CSS | PostgreSQL | React | Redux