作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在我的应用程序上添加多个 Action 效果。但我想我错过了一些东西。效果函数没有被调用。我希望命名有问题吗?理想情况下 yield all([
这应该可以解决问题,对吧?帮我想想办法。
action.js
import {
DEFAULT_ACTION,
POST_ADMIN_LOGIN_REQUEST,
POST_ADMIN_LOGIN_REQUEST_SUCCESS,
POST_ADMIN_LOGIN_REQUEST_ERROR,
POST_ADMIN_USER_DETAILS,
} from './constants';
import { setCookie } from '../../utils/helpers';
...... //rest of my actions
export function postAdminUserDetails(token) {
console.log(token);
// I see token in the console
return {
type: POST_ADMIN_USER_DETAILS,
token,
};
}
常量.js
export const POST_ADMIN_USER_DETAILS = 'app/AdminLogin/POST_ADMIN_USER_DETAILS';
saga.js
import { takeLatest, call, put, all } from 'redux-saga/effects';
import request from 'utils/request';
import { POST_ADMIN_LOGIN_REQUEST, POST_ADMIN_USER_DETAILS } from './constants';
console.log(POST_ADMIN_USER_DETAILS)
import {
postAdminLoginRequestSuccess,
postAdminLoginRequestError,
} from './actions';
export function* triggerLogin({ params }) {
const requestURL = new URL(`${API}/login`);
...... //rest of the logis, which is working
}
export function* triggerGetUser({ token }) {
const requestURL = new URL(`${API}/profile`);
console.log('callllled');
// this is not even getting called :(
}
export default function* defaultSaga() {
console.log('POST_ADMIN_USER_DETAILS')
yield all([
takeLatest(POST_ADMIN_LOGIN_REQUEST, triggerLogin),
takeLatest(POST_ADMIN_USER_DETAILS, triggerGetUser),
]);
}
reducer .js
import { fromJS } from 'immutable';
import {
DEFAULT_ACTION,
POST_ADMIN_LOGIN_REQUEST,
POST_ADMIN_LOGIN_REQUEST_SUCCESS,
POST_ADMIN_LOGIN_REQUEST_ERROR,
POST_ADMIN_USER_DETAILS,
} from './constants';
export const initialState = fromJS({
isLogin: false,
hasError: false,
loginResponse: null,
});
function adminLoginReducer(state = initialState, action) {
switch (action.type) {
case DEFAULT_ACTION:
return state;
case POST_ADMIN_LOGIN_REQUEST:
return state
.set('isLogin', true)
.set('hasError', false)
.set('errorMessage', null)
.set('loginResponse', null);
case POST_ADMIN_LOGIN_REQUEST_SUCCESS:
return state
.set('isLogin', false)
.set('hasError', false)
.set('loginResponse', action.response);
case POST_ADMIN_LOGIN_REQUEST_ERROR:
return state
.set('isLogin', false)
.set('hasError', true)
.set('errorMessage', action.errorMessage);
case POST_ADMIN_USER_DETAILS:
return state;
default:
return state;
}
}
export default adminLoginReducer;
最佳答案
我也遇到过同样的问题,通过更改文件夹路径解决了它。因此,请尝试相同的操作,或者尝试将 saga 文件保留在与组件文件相同的文件夹级别。
关于javascript - 为什么传奇效应没有被调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54835561/
图像显示,但不转换。 CSS 代码显示在上传的页面上。 我正在使用 EverWeb 构建页面。 下面是我正在尝试的代码。提前致谢。 HTML 片段 CSS .image { width: 100
我是一名优秀的程序员,十分优秀!