Use case
I have a requirement, if name is equal to durian I want to change country dropdown’s value to the France. For the moment I am doing this with middleware like this
const middleware = useCallback((state, action, defaultReducer) => {
const newState = defaultReducer(state, action);
switch (action.type) {
case INIT:
case UPDATE_CORE:
case UPDATE_DATA: {
if (newState.data.name === 'durian') {
newState.data.country = 'france';
}
return newState;
}
default:
return newState;
}
}, []);
The problem with this approach is for each and every condition we need to add code in front end. We want to save this conditions to the backend in some form of json schema like this
{
"data": {
"name": "durian",
"country": "france"
}
}
Can we do this with JSON forms without a middleware?