Answer the question
In order to leave comments, you need to log in
Questions about React'y / Redux'y?
Hello. In order not to create questions 10 times, I will write in one, everything that interests me.
1. In real projects, do you use CRA or do you set up the project yourself (along with webpack, etc.)?
2.
createReducer(initialState, mainAction, {
actionName: reducerHelper
})
???const createQuestionUpdate = (state, action) => {
switch (action.type) {
case `${CREATE_QUESTION}_UPDATE`:
const {data, path } = action.payload;
const res = set(state, path, data);
return Object.assign({}, res);
default:
return state;
}
};
export default createReducer(Object.assign({}, InitialState), CREATE_QUESTION, {
[`${CREATE_QUESTION}_UPDATE`] : createQuestionUpdate
});
export const onChange = (e, val = "value") => dispatch => {
let type = e.target.name; //actionType
let property = e.target.id;
let value = e.target[val]; // input value
let { errors } = validate[type]({ [property]: value }); // error object for all related inputs
dispatch([
{
type: type,
payload: { [property]: value }
},
{
type: `${type}_ERROR`,
payload: {
errors: { [property]: get(errors, property) }
}
}
]);
};
Answer the question
In order to leave comments, you need to log in
1.
By ourselves 2. We write with pens (+10 to readability, +10 to static analysis, -100 to cognitive load) Of course, if you write a dashboard with a bunch of models, it makes sense to write a CRUD Boilerplate
3. In 99.99% of cases, storing the state of forms in the store is meaningless and unjustified
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question