Skip to content

Commit

Permalink
Refactor: Increase the formatting tool prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
starriv committed Apr 20, 2017
1 parent 0d018b0 commit 6aeecbd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 25 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
<!--<script src="http://127.0.0.1:3002/assert/bundle.js"></script>-->
<script src="http://127.0.0.1:3002/assert/bundle.js"></script>
</body>

</html>
4 changes: 2 additions & 2 deletions src/actions/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as ActionType from '../constants/ActionTypes'

export function ADD_MESSAGE(data) {
export function ADD_MESSAGE (data) {
data.id++
data.text = 'welcome use Redux' + data.id
console.log(data)
return {
type: ActionType.ADD_MESSAGE,
data,
data
}
}
18 changes: 5 additions & 13 deletions src/containers/App.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import Hello from '../components/hello/hello'
import { ADD_MESSAGE } from '../actions'

class App extends Component {
render() {
return <Hello />
}
}

// 哪些 Redux 全局的 state 是我们组件想要通过 props 获取的?
function mapStateToProps(state) {
function mapStateToProps (state) {
return { addmessage: state.addmessage }
}

// 哪些 action 创建函数是我们想要通过 props 获取的?
function mapDispatchToProps(dispatch) {
function mapDispatchToProps (dispatch) {
return {
actions: bindActionCreators(
{
ADD_MESSAGE,
ADD_MESSAGE
},
dispatch,
),
dispatch
)
}
}

Expand Down
18 changes: 9 additions & 9 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import ReactDOM from 'react-dom'
import {createStore, applyMiddleware} from 'redux'
import {Provider} from 'react-redux'
import {Provider} from 'react-redux'
import {Route} from 'react-router'
import {ConnectedRouter, routerMiddleware} from 'react-router-redux'
import createHistory from 'history/createBrowserHistory'
Expand All @@ -19,13 +19,13 @@ history = createHistory(store)
const node = document.getElementById('app')

ReactDOM.render(
<Provider store={store}>
{ /* ConnectedRouter will use the store from Provider automatically */ }
<ConnectedRouter history={history}>
<div>
<Route exact path="*" component={App}/>
</div>
</ConnectedRouter>
</Provider>,
<Provider store={store}>
{ /* ConnectedRouter will use the store from Provider automatically */ }
<ConnectedRouter history={history}>
<div>
<Route exact path='*' component={App} />
</div>
</ConnectedRouter>
</Provider>,
node
)

0 comments on commit 6aeecbd

Please sign in to comment.