BindActionCreators yog dab tsi?
BindActionCreators yog dab tsi?

Video: BindActionCreators yog dab tsi?

Video: BindActionCreators yog dab tsi?
Video: Yog Vim Dab Tsi Guitar​ Chords 2024, Kaum ib hlis
Anonim

# bindActionCreators (actionCreators, dispatch) Tig ib yam khoom uas nws qhov tseem ceeb yog tus tsim tsim, rau hauv ib yam khoom uas muaj tib tus yuam sij, tab sis nrog txhua tus tsim kev ua haujlwm tau qhwv rau hauv kev xa xov yog li lawv yuav raug hu ncaj qha. Feem ntau koj yuav tsum tsuas yog hu xov tooj ncaj qha rau ntawm koj lub khw muag khoom.

Ib yam li ntawd, nws tau nug, siv mapDispatchToProps yog dab tsi?

Muab ib mapDispatchToProps tso cai rau koj txheeb xyuas cov kev ua uas koj cov khoom yuav xav tau xa mus. Nws tso cai rau koj muab kev txiav txim xa tawm ua haujlwm raws li cov khoom siv. Yog li ntawd, es tsis txhob hu props.

Tom qab ntawd, lo lus nug yog, Dispatch hauv react JS yog dab tsi? xa () yog txoj kev siv los xa kev ua thiab ua rau lub xeev hloov mus rau lub khw. teb -redux tsuas yog sim muab koj yooj yim nkag mus rau nws. Nco ntsoov, txawm li cas los xij, qhov ntawd xa tsis muaj nyob rau ntawm props yog tias koj ua dhau hauv kev ua rau koj txoj haujlwm txuas.

Tom qab ntawd, ib tug kuj yuav nug, dab tsi yog tus tsim tsim?

Ib tus tsim tawm tsuas yog ib txoj haujlwm uas rov qab los kev ua khoom. Hu ib tus tsim tawm tsis muaj dab tsi tab sis xa rov qab ib yam khoom, yog li koj yuav tsum khi nws mus rau lub khw ua ntej, lossis xa cov txiaj ntsig ntawm kev hu koj tus tsim tawm.

Qhov txawv ntawm mapStateToProps thiab mapDispatchToProps yog dab tsi?

3 Teb. mapStateToProps yog ib txoj haujlwm uas koj yuav siv los muab cov ntaub ntawv khaws cia rau koj cov khoom, whereas mapDispatchToProps yog ib yam dab tsi uas koj yuav siv los muab cov neeg tsim ua yeeb yam ua khoom siv rau koj cov khoom.

Pom zoo: