我正在尝试将一个文件中的常量导入另一个文件。
这是导出常量的文件:
import {
GET_CATALOGS,
GET_CATALOGS_SUCCESS,
SHOW_MESSAGE,
ON_CRUD_POPULATE_LIST,
CRUD_POPULATE_LIST_SUCCESS
ON_CRUD_FETCH_NEXT_PAGE,
CRUD_FETCH_NEXT_PAGE_SUCCESS,
ON_CRUD_FETCH_PREVIOUS_PAGE,
CRUD_FETCH_PREVIOUS_PAGE_SUCCESS,
ON_CRUD_FETCH_RECORD,
CRUD_FETCH_RECORD_SUCCESS,
ON_CRUD_CREATE,
CRUD_CREATE_SUCCESS,
ON_CRUD_UPDATE,
CRUD_UPDATE_SUCCESS,
ON_CRUD_DELETE,
CRUD_DELETE_SUCCESS
} from 'constants/ActionTypes';
export const getCatalogs = (group) => {
return {
type: GET_CATALOGS,
payload: group
};
};
export const getCatalogsSuccess = (catalogs) => {
return {
type: GET_CATALOGS_SUCCESS,
payload: catalogs
}
};
export const showCatalogsMessage = (message) => {
return {
type: SHOW_MESSAGE,
payload: message
};
};
export const setCurrentCatalog = (catalog) => {
return {
type: SET_CURRENT_CATALOG,
payload: catalog
}
};
export const crudPopulateList = (catalog) => {
return {
type: ON_CRUD_POPULATE_LIST,
payload: catalog
}
};
export const crudPopulateListSuccess = (page) => { /// This is the constant that can't be imported
return {
type: CRUD_POPULATE_LIST_SUCCESS,
payload: page
}
};
export const crudFetchNextPage = () => {
return {
type: ON_CRUD_FETCH_NEXT_PAGE,
payload: null
}
};
export const crudFetchNextPageSuccess = (page) => {
return {
type: CRUD_FETCH_NEXT_PAGE_SUCCESS,
payload: (page)
}
};
export const crudFetchPreviousPage = () => {
return {
type: ON_CRUD_FETCH_PREVIOUS_PAGE,
payload: null
}
};
export const crudFetchPreviousPageSuccess = (page) => {
return {
type: CRUD_FETCH_PREVIOUS_PAGE_SUCCESS,
payload: (page)
}
};
export const crudFetchRecord = (id) => {
return {
type: ON_CRUD_FETCH_RECORD,
payload: id
}
};
export const crudFetchRecordSuccess = (record) => {
return {
type: CRUD_FETCH_RECORD_SUCCESS,
payload: record,
}
};
export const crudCreate = (payload) => {
return {
type: ON_CRUD_CREATE,
payload: payload
}
};
export const crudCreateSuccess = (record) => {
return {
type: CRUD_CREATE_SUCCESS,
payload: record
}
};
export const crudUpdate = (payload) => {
return {
type: ON_CRUD_UPDATE,
payload: payload
}
};
export const crudUpdateSuccess = (record) => {
return {
type: CRUD_UPDATE_SUCCESS,
payload: record
}
};
export const crudDelete = (id) => {
return {
type: ON_CRUD_DELETE,
payload: id
}
};
export const crudDeleteSuccess = (id) = {
return {
type: CRUD_DELETE_SUCCESS,
payload: id
}
};
这是我尝试导入常量的文件:
import {all, call, fork, put, takeEvery} from "redux-saga/effects";
import {catalogs} from 'backend/Catalogs';
import {
GET_CATALOGS,
CRUD_POPULATE_LIST
} from "constants/ActionTypes";
import {
getCatalogs,
getCatalogsSuccess,
showCatalogsMessage,
crudPopulateListSuccess /// Here is where I try to import the constant
} from 'actions/Catalogs';
const getCatalogsRequest = async (group) =>
await catalogs.getCatalogs(group)
.then(catalogsList => catalogsList)
.catch(error => error);
function* getCatalogsListFromRequest({payload}) {
const {group} = payload;
try {
const catalogsList = yield call(getCatalogsRequest, group);
if (catalogsList.message) {
yield put(showCatalogsMessage(catalogsList.Message));
} else {
yield put(getCatalogsSuccess(catalogsList))
}
} catch (error) {
yield put(showCatalogsMessage(error));
}
}
export function* getCatalogsList() {
yield takeEvery(GET_CATALOGS, getCatalogsListFromRequest);
}
const crudPopulateListRequest = async (url) =>
await catalogs.crudPopulateList(url)
.then(page => page)
.catch(error => error);
function* crudPopulateListFromRequest({payload}) {
const {catalog} = payload
try {
const page = yield call(crudPopulateListRequest, catalog.url)
if (page.message) {
yield put(showCatalogsMessage(page.list));
} else {
yield put(crudPopulateListSuccess(page));
}
} catch (error) {
yield put(showCatalogsMessage(error));
}
}
export function* crudPopulateList() {
yield takeEvery(ON_CRUD_POPULATE_LIST, crudPopulateListFromRequest);
}
export default function* rootSaga() {
yield all([
fork(getCatalogsList),
fork(crudPopulateList),
fork(crudFetchNextPage),
fork(crudFetchPreviousPage),
fork(crudFetchRecord),
fork(crudCreateRecord),
fork(crudUpdateRecord),
fork(crudDeleteRecord)
]);
}
我可以确定该常量存在,就像之前导入的常量一样,但是,我仍然收到此错误:
我不知道自己在做什么错。