Dab tsi yog reducer hauv react JS?
Dab tsi yog reducer hauv react JS?

Video: Dab tsi yog reducer hauv react JS?

Video: Dab tsi yog reducer hauv react JS?
Video: Leng Yang - Yog Vim Dab Tsi (Official Full Song | Nkauj Tawm Tshiab) 2020/05/24 2024, Kaum ib hlis
Anonim

Cov reducer yog ib tug ntshiab muaj nuj nqi uas yuav siv sij hawm lub xeev dhau los thiab ib qho kev txiav txim, thiab rov qab rau lub xeev tom ntej. (previousState, action) => NextState. Nws hu ua a reducer vim nws yog hom kev ua haujlwm koj yuav dhau mus rau Array.

Kuj paub yog, dab tsi yog reducer nyob rau hauv react?

react reducer redux lub xeev kev tswj hwm. Kawm Kev Txhim Kho ntawm Frontend Masters. A reducer yog ib txoj haujlwm uas txiav txim siab hloov pauv rau daim ntawv thov lub xeev. Nws siv qhov kev txiav txim uas nws tau txais los txiav txim qhov kev hloov pauv no.

Tom qab ntawd, lo lus nug yog, dab tsi yog redux hauv react JS? Redux yog lub xeev cov thawv uas xav tau rau JavaScript apps. Nws pab koj sau cov ntawv thov uas coj tus cwj pwm tsis tu ncua, khiav hauv ib puag ncig sib txawv (tus neeg siv khoom, server, thiab haiv neeg), thiab yooj yim rau kev sim. Koj siv tau Redux ua ke nrog Teb , los yog nrog lwm lub tsev qiv ntawv saib.

Tsis tas li ntawd paub, vim li cas reducers ntshiab?

Yog lawm, ntshiab reducers yog deterministic, txhais tau hais tias yog hais tias lawv muab tib lub tswv yim, lawv yuav yeej ib txwm tsim ib yam kev tshwm sim. Cov cuab yeej no pab nrog cov xwm txheej zoo li kev sim ntsuas, vim tias koj paub tias qhov kev xeem dhau ib zaug, nws yuav dhau mus tas li.

Dab tsi yog qhov kev txiav txim hauv react?

Raws li ib tug refresher, ib kev ua yog ib yam khoom yooj yim uas yuav tsum suav nrog tus nqi. Peb tsim ib hom. js cov ntaub ntawv uas tuav rau kev ua type constants, yog li peb tuaj yeem siv cov txiaj ntsig no ua cov cuab yeej. Raws li kev tshuaj xyuas sai, peb kev ua tuaj yeem yog txhua yam khoom muaj nqis uas muaj tus yuam sij.

Pom zoo: