我对 react-native 和 Viro-react 平台非常陌生。目前,我正在为我最后一年的项目开发一个 AR/VR 应用程序。在那个项目中,我需要应用 redux 功能并为我的整个应用程序实现一个公共存储。我已经正确地创建了store/index.js
(store), ( store/reducer/index.js
root reducer) & 。以下是他们。store/reducer/initial_Reducer.js
store/actions/initial_Action.js
商店/index.js(商店)
import rootReducer from './reducers';
import {createStore} from 'redux';
const store = createStore(rootReducer);
export default store;
store/reducer/index.js(根减速器)
import initial_Reducer from './initial_Reducer';
import { combineReducers } from 'redux';
const rootReducer = combineReducers({
initial_Reducer: initial_Reducer,
});
export default rootReducer;
存储/reducer/initial_Reducer.js
const initial_Reducer = (state = {store:true}, action) => {
console.log("Initial Reducer..");
switch (action.type) {
case 'initialize': {
return state;
}
default:
return state;
}
}
export default initial_Reducer;
存储/操作/initial_Action.js
export const initializeStore = () => {
console.log("Initial Action..");
return {
type: 'initialize'
}
}
当我尝试将商店应用到带有标签时,它给了我以下错误。
React is not defined
我的 index.js & index.android.js 如下。
index.js
import { AppRegistry } from 'react-native';
import App from './App.js';
import store from './store/index'; //importing redux store config from store/index.js
import { Provider } from 'react-redux/src'; //importing binding layer from reac-redux
// The below line is necessary for use with the TestBed App
AppRegistry.registerComponent('ViroSample', () =>
<Provider store={store} >
<App />
</Provider>
);
index.android.js
import { AppRegistry } from 'react-native';
import App from './App.js';
import store from './store/index'; //importing redux store config from store/index.js
import { Provider } from 'react-redux/src' //importing binding layer from reac-redux
// The below line is necessary for use with the TestBed App
AppRegistry.registerComponent('ViroSample', () =>
<Provider store={store} >
<App />
</Provider>
);