1
「店のエラーを見つけることができませんでした」の基本的な反応ネイティブReduxのアプリ投げを行い、ネイティブ反応し、私は基本的なアプリ私が始めるためにしようとしている
Could not find "store" in either the context or props of "Connect(App)". Either wrap the root component in a <Provider>, or explicitly pass "store" as a prop to "Connect(App)".
に次のエラーを取得していますなぜここに私のコードは
import React, { Component, PropTypes } from 'react';
import { Text } from 'react-native';
import { createStore, combineReducers, applyMiddleware, compose } from 'redux';
import { Provider, connect } from 'react-redux';
import thunk from 'redux-thunk';
import reducer from './reducers/counter';
const store = createStore(
combineReducers({
counter: reducer,
}),
{}, // initial state
compose(
applyMiddleware(thunk),
),
);
class App extends Component {
constructor(props) {
super(props);
}
componentDidMount() {
}
render() {
return (
<Provider store={store}>
<Text>Hello World</Text>
</Provider>
);
}
}
App.propTypes = {
dispatch: PropTypes.func.isRequired,
counter: PropTypes.number,
};
function mapStateToProps(state) {
return {
counter: state,
};
}
export default connect(mapStateToProps)(App);
だと、ここで減速です:
// ./reducers/counter.js
export default (state = 0, action) => {
switch (action.type) {
case 'INCREMENT':
return state + 1
case 'DECREMENT':
return state - 1
default:
return state
}
}