ReactJS Real time Interview Questions
Once you have a store set up (with actions, actionCreators and reducers), how do you make sure your app knows about the store?
Ans:
import { Provider } from 'react-redux';
import store, { history } from './store';
wrap the whole <Router> within the <Provider> tags
make sure Router draws from {history} instead of {browserHistory}
<Provider store={store}>
<Router history={history}>
<Route path="/" component={Main}>
<IndexRoute component={PhotoGrid}></IndexRoute>
<Route path="/view/:postId" component={Single}></Route>
</Route>
</Router>
</Provider>
What are the 2 ways props are used?
As dynamic attribute values, or dynamic element content.
e.g.
render: function() {
return (
<div className='photo'>
<img src={this.props.src} />
<span>{this.props.caption}</span>
</div>
);
}
Ans:
import { Provider } from 'react-redux';
import store, { history } from './store';
wrap the whole <Router> within the <Provider> tags
make sure Router draws from {history} instead of {browserHistory}
<Provider store={store}>
<Router history={history}>
<Route path="/" component={Main}>
<IndexRoute component={PhotoGrid}></IndexRoute>
<Route path="/view/:postId" component={Single}></Route>
</Route>
</Router>
</Provider>
What are the 2 ways props are used?
As dynamic attribute values, or dynamic element content.
e.g.
render: function() {
return (
<div className='photo'>
<img src={this.props.src} />
<span>{this.props.caption}</span>
</div>
);
}
Comments