[英]import error from react project during build time
我在 React 項目的 2 個文件中遇到了導入問題。 我附上了我的本地主機 3000 的屏幕截圖:請幫我解決問題。 我提供了這兩個文件的代碼。
這是 index.js 文件代碼
export {
addIngredient,
removeIngredient,
initIngredients
} from './burgerBuilder';
export {
purchaseBurger, purchaseInit, fetchOrders
} from './order';
這是 burgerBuilder.js 代碼:
// only synchronous action creators for adding n removing ingredients
import * as actionTypes from './actionTypes';
import axios from '../../axios-orders';
export const addIngredients =(name) =>{
return{
type: actionTypes.ADD_INGREDIENT,
ingredientName: name
};
}
export const removeIngredients =(name) =>{
return{
type: actionTypes.REMOVE_INGREDIENT,
ingredientName: name
};
};
export const setIngredients = (ingredients) => {
return{
type: actionTypes.SET_INGREDIENTS,
ingredients: ingredients
};
}
export const fetchIngredientsFailed = () => {
return{
type: actionTypes.FETCH_INGREDIENTS_FAILED
};
}
//init is shrt frm of initialization
export const initIngredients = () => {
//return an action here
return dispatch => {
axios.get('https://react-my-burger-b5132.firebaseio.com/ingredients.json')
.then(response =>{
dispatch(setIngredients(response.data));
})
.catch(error =>{
dispatch (fetchIngredientsFailed());
});
};
};
您的再導出名稱與 burgerBuilder.js 中的導出名稱不匹配。 例如,您正在導出“addIngredients”,但重新導出不同的名稱“addIngredient”。 名稱必須全部匹配。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.