0
さまざまなコンポーネントをt-reduxで管理されている状態に接続する必要がありますが、t-reduxはreducerといくつかの初期状態を受け入れるだけのwithState()関数しか持たないようです。したがって、すべてのコンポーネントは「新しい状態」を受け取っているようです。t-reduxライブラリに、reduxの公式接続関数のように機能する関数はありますか?
ライブラリは、これが一つです:あなたは、各高次成分が含まれていることを、あなたが表示されますT-再来のwithStateの実装を見てみるとこれが公式の例
// import the needed modules
import {withState, dispatcher, buildReducer} from 't-redux'
// this is a PORC (Plain Old React Component)
class MyCounter extends React.Component {
constructor() {
super()
this.plusOne = this.plusOne.bind(this)
}
plusOne() {
// Dispacth the action (the content is optional)
dispatcher.dispatch({type: 'PLUS_ONE', content: this.props.counter})
}
render() {
return (
<div>
<div>Click count: {this.props.counter}</div>
<button onClick={this.plusOne}>Add 1</button>
</div>)
}
}
// Build the reducers as a map ACTION:(state, action) => state
const reducers = buildReducer({
'PLUS_ONE': (state, action) => ({counter: state.counter + 1})
})
// Define the initial state
const INITIAL_STATE = { counter: 0 }
// export the wrapped component passing the reducers and the initial state
export default withState([reducers], INITIAL_STATE)(MyCounter)
ありがとうございました。私はt-redux哲学を誤解しました。 –