reactjs - 我们如何从 SAGA 中的生成器函数中导出变量?
问题描述
export function* getContacts(action: PayloadAction<SearchQuery>) {
const stationCode = action.payload.stationCode;
console.log(stationCode);////// Want stationCode from here to outside
const requestURL = `${API_PATH}contacts/departments/${stationCode}`;
const requestOptions = {
credentials: 'same-origin',
method: 'GET',
};
try {
yield put(actions.setIsLoading(true));
let contactList = yield call(request, requestURL, requestOptions);
transformContacts(contactList);
yield put(actions.setContactRecords(contactList));
yield put(actions.setIsLoading(false));
} catch (err: any) {
let errorObject: ErrorObject = { status: err.status, message: '' };
if (err.status === 400) {
errorObject.message = 'Invalid Station Code';
} else {
errorObject.message =
'We are observing a technical issue...Please try again later';
}
yield put(actions.loadStationsError(errorObject));
yield put(actions.setIsLoading(false));
}
// return stationCode;
}
如何将站代码从那里导出到另一个组件?出口不工作 EG:出口 const stationCode = action.payload.stationCode 不工作
解决方案
推荐阅读
- reactjs - 在具有动态创建路径的 SSG NextJS 站点上使用 initialApolloState
- html - 如何使用 HTML 和 CSS 重新创建相同的 Angular Material 切换选择代码?
- numpy - 如何使用单应性将两个相机 FOV 转换为一个显示图像
- node.js - Create-react-app 不适用于已安装的 npm 版本
- firebase - 发送 Google Firebase 命令时的数据队列
- reactjs - 如何移除旋转木马下方的部件?
- python - Django中敏感数据的加密模型字段
- javascript - 无法在 Django 中传递字典
- node.js - 升级 Node.js 时的 SequelizeConnectionError(4x 到 7x)
- mysql - vb.net - 基于任务的 SQL 类“一个一个”地处理 SQL 查询