引入redux和react-redux之后,入口文件如何保持和以前react时候一样的的写法

@ckinmind 2017-01-25 12:11:06发表于 ckinmind/ReactCollect 待处理重要

没有引入redux的react项目,一般入门文件类似下面这样的

import React from 'react';
import ReactDOM from 'react-dom';
import App from './conponent/App';

ReactDOM.render(<App/>, document.getElementById('app'));

而引入了redux(react-redux)的react的项目,其入口文件是这样的

import React from 'react'
import ReactDOMfrom 'react-dom'
import App from './components/App'

import { createStore } from 'redux'
import { Provider } from 'react-redux'
import reducer from './reducers'

const store = createStore(reducer);


ReactDOM.render(
  <Provider store={store}>
    <App />
  </Provider>,
  document.getElementById('app')

上面这种写法的在react开发者工具里查看到的结构是这样的

 <Provider store = {...}>
        <App>
                 ......
         </App>
 </Provider>