我正在尝试在继承的小部件/状态中调用设置状态 遵循此说明 https://medium.com/flutter-community/widget-state-buildcontext-inheritedwidget-898d671b7956
在我不熟练的人看来,他在做同样的事情, 但显然我错过了一些东西; 你能帮我吗?
import {
SECOND_SYSTEM_AUTHENTICATE_REQUEST,
SECOND_SYSTEM_AUTHENTICATE_SUCCESS,
SECOND_SYSTEM_AUTHENTICATE_FAILURE,
} from 'actions/authentication/authentication-actions';
export const defaultState = {
isFetching: false,
hasRequested: false,
error: '',
customerToken: ''
};
/**
* Reducer for authentication
* @param {Object} state
* @param {Object} action
* @returns {Object} updated state
*/
export default function (state = defaultState, action) {
switch (action.type) {
case SECOND_SYSTEM_AUTHENTICATE_REQUEST:
return Object.assign({}, state, {
isFetching: true,
hasRequested: true
});
case SECOND_SYSTEM_AUTHENTICATE_SUCCESS:
return Object.assign({}, state, {
isFetching: false
});
提前感谢您的帮助
答案 0 :(得分:1)
您错过了() =>
onPressed: () => state.deal(input)
您的代码将调用state.deal(input)
的结果传递给onPressed
,而上面的代码传递了一个函数,该函数在被调用时调用state.deal(input)