987 B
987 B
title, localeTitle
| title | localeTitle |
|---|---|
| Extract State Logic to Redux | استخراج الدولة المنطق إلى Redux |
استخراج الدولة المنطق إلى Redux
هذا هو كعب. ساعد مجتمعنا على توسيعه .
سيساعدك دليل النمط السريع هذا على ضمان قبول طلب السحب .
الحل المقترح:
const ADD = 'ADD';
function addMessage(message) {
return {
type: ADD,
message: message
};
};
function messageReducer (previousState, action) {
return [...previousState, action.message];
}
let store = {
state: [],
getState: () => store.state,
dispatch: (action) => {
if (action.type === ADD) {
store.state = messageReducer(store.state, action);
}
}
};