هل يمكن دمج المخفضات أم يجب استخدامها مرة واحدة لدمج جميع المخفضات في واحدة؟
هل هذا أسلوب سيء لإنشاء هيكل شجرة مخزن من خلال الجمع بين المخفضات في كل خطوة؟
أو ربما هناك أي طريقة أخرى للحفاظ على نظافة مخزن الجذر (تريد تجنب وضع جميع أوراق الشجر في مخزن الجذر)
مثال على بنية الكود الكاذب:
rootReducer = combineReducers({
router, // redux-react-router reducer
account: combineReducers({
profile: combineReducers({
info, // reducer function
credentials // reducer function
}),
billing // reducer function
}),
// ... other combineReducers
})
});
بالتأكيد ، إنها فكرة جيدة.
مرحبًا ، نفذت برنامج دمج متعدد ،
// schoolReducer.js
export default combineReducers({
company: companyReducer,
profile: profileReducer,
});
// studentInfo.js
export default combineReducers({
student: studentReducer,
course: courseReducer,
});
//rootReducer.js
export default combineReducers({
school: schoolReducer,
student: studentInfo,
});
وجود خطأ
Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.
@ justinlazaro-ubidy:
هذا هو تعقب الأخطاء ، وليس نظام دعم. بالنسبة لأسئلة الاستخدام ، يرجى استخدام Stack Overflow أو Reactiflux حيث يوجد الكثير من الأشخاص المستعدين لمساعدتك - ربما تحصل على إجابة أفضل بشكل أسرع. شكر!
التعليق الأكثر فائدة
بالتأكيد ، إنها فكرة جيدة.