ユーザ用ツール

サイト用ツール


reactnative:react-redux

差分

この文書の現在のバージョンと選択したバージョンの差分を表示します。

この比較画面にリンクする

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
reactnative:react-redux [2019/01/31 06:52]
ips
reactnative:react-redux [2019/02/02 03:04] (現在)
ips
ライン 3: ライン 3:
 <​code>​ <​code>​
 >npm install react-redux >npm install react-redux
->npm install redux+</​code>​ 
 + 
 +SyntaxError:​ C:​\Users\Ryu\react\expo-redux\App.js:​ Only one default export allowed per module. 
 +<​code>​ 
 +>npm install redux 
 </​code>​ </​code>​
  
ライン 94: ライン 98:
  
  
 +==== エラー1 ====
 +<​code>​
 +Invariant Violation: Could not find "​store"​ in the context of "​Connect(App)"​. Either wrap the root component in a <​Provider>,​ or pass a custom React context provider to <​Provider>​ and the corresponding React context consumer to Connect(App) in connect options.
 +</​code>​
 +expoを使っているとApp.jsがエントリーポイントだった。
  
  
 +==== エラー2 ====
 +<​code>​
 +Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/​function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
 +
 +Check the render method of `App`.
 +</​code>​
 +
 +インポート元を間違っていた…
 +x import {Provider} from '​react-native'​
 +o import {Provider} from '​react-redux'​
 +
 +==== エラー3 ====
 +<​code>​
 +TypeError: Cannot read property '​getState'​ of undefined
 +</​code>​
 +いつの間にかエラーが消えてしまったがProviderとstateあたりが問題だった
 +
 +<​code>​
 +import React from '​react';​
 +import { createStore,​ combineReducers } from '​redux';​
 +import { Provider } from '​react-redux'​
 +import Container from '​./​components/​Container'​
 +import countReducerValue from '​./​reducers/​countReducer'​
 +import nameReducerValue from '​./​reducers/​nameReducer'​
 +
 +
 +const rootReducer = combineReducers({
 +    count: countReducerValue,​
 +    name: nameReducerValue,​
 +  })
 +  ​
 +const store = createStore(rootReducer)
 +
 +
 +export default class App extends React.Component {
 +    render(){
 +        // console.log("​App.render()"​)
 +        // store.subscribe(() => console.log("​xxxx:"​ + store.getState()))
 +        return(
 +             <​Provider store={store}>​
 +                <​Container/>​
 +             </​Provider>​
 +        )
 +    }
 +}
 +
 +</​code>​
reactnative/react-redux.1548885134.txt.gz · 最終更新: 2019/01/31 06:52 by ips