یلدا ادامه داره... ❤️ ۴۰ درصد تخفیف همه دورهها
استفاده از تخفیفهاسلام من expo react native یه پروژه ساده درست کردم که redux رو بهش اضافه کردم
ولی یه خطا بهم میده وقتی npm start میزنم و روی android میخوام اجراش کنم
//app.js
//react
import React from 'react';
//redux
import { createStore} from 'redux' ;
import { Provider } from 'react-redux';
//root reducer
import RootReducer from '/store/RootReducer';
//expo
import { AppLoading } from "expo";
import { useFonts } from 'expo-font';
//Main navigation
import Main from "./navigation/Main";
export default function App() {
//create store
const store = createStore(RootReducer);
//load fonts
let [fontsLoaded] = useFonts({
'vazir': require('./assets/fonts/Vazir.ttf'),
});
//render app if fonts loaded
if (!fontsLoaded)
return <AppLoading />
else
return (<Provider store={store}> <Main /> </Provider>)
}
//RootReducer.js
import { combineReducers } from "redux";
import user from "./reducers/user";
const RootReducer = combineReducers({
user : user
});
export default RootReducer ;
//user.js
import {LOGIN, LOGOUT} from "../actions/user";
const initialState = {
user: null,
};
export default (state = initialState, action) => {
switch(action.type){
case LOGIN:
return state.user = action.payload.user
case LOGOUT:
return state.user = null
default:
return state
}
};
//main.js navigator
import { createStackNavigator} from "react-navigation-stack";
import { createAppContainer } from "react-navigation";
import Login from "../screens/Login";
import Home from "../screens/Home";
const Main = createStackNavigator(
{
Login : Login ,
Home : Home ,
},
{
defaultNavigationOptions: {
layout: 'rtl' ,
headerTitleAlign : 'center' ,
headerTintColor : 'white' ,
headerStyle : {
backgroundColor : '#3949ab' ,
}
}
})
export default createAppContainer(Main) ;
فایل های پروژه بالاست
خطایی که نشون میده
Failed building JavaScript bundle.
Unable to resolve "/store/RootReducer" from "App.js"
حل شد
app.js
import RootReducer from '/store/RootReducer';
import RootReducer from './store/RootReducer';
مشکل فقط import بود
آیا مایل به ارسال نوتیفیکیشن و اخبار از طرف راکت هستید ؟