Reputation: 107
My problem is react-route display blank page and no error display in console or webpack. I try to delete all Router and replace by App but it show me blank page agian.
This is my main.js file.
import React from 'react'
import ReactDOM from 'react-dom'
import {Provider} from 'react-redux'
import {createStore, combineReducers} from 'redux'
import { Router, Route, browserHistory, IndexRoute } from 'react-router'
import Index from './containers/Index.js'
import App from './containers/App.js'
import pollReducer from './reducers/pollReducer.js'
var reducers = combineReducers({
poll: pollReducer
})
var store = createStore(reducers);
ReactDOM.render(
<Provider store={store}>
<Router>
<Route path="/" component={Index} />
<Route path="/question" component={App} />
</Router>
</Provider>
, document.getElementById('app'))
and this is my App and Index js file
import React from 'react'
class App extends React.Component {
render(){
return(
<div>
This is App page
</div>
)
}
}
export default App
This is my Index.js file
import React from 'react'
class Index extends React.Component {
render(){
return(
<div>
This is asdasdasda
</div>
)
}
}
export default Index
Thank you for help.
Upvotes: 2
Views: 4937
Reputation: 104359
Because you forgot to define the history
, Use this:
<Router history={browserHistory}>
<Route path="/" component={Index} />
<Route path="/question" component={App} />
</Router>
Upvotes: 1