Yog vim li cas yog react immutable?
Yog vim li cas yog react immutable?

Video: Yog vim li cas yog react immutable?

Video: Yog vim li cas yog react immutable?
Video: Yog Vim Li Cas Karaoke by Yis Vwj 2024, Kaum ib hlis
Anonim

Immutability yog ib lub tswvyim uas Teb programmers yuav tsum to taub. Ib hloov tsis tau tus nqi lossis khoom tsis tuaj yeem hloov pauv, yog li txhua qhov hloov tshiab tsim tus nqi tshiab, tawm hauv qhov qub tsis tau kov. Nco ntsoov, raws li nrog ntau yam hauv programming, nws yog kev lag luam tawm.

Hauv qhov no, dab tsi yog mutable thiab immutable nyob rau hauv react?

A hloov tau khoom yog ib yam khoom uas nws lub xeev tuaj yeem hloov kho tom qab nws tsim. Ib hloov tsis tau khoom yog ib yam khoom uas lub xeev tsis tuaj yeem hloov kho tom qab nws tsim.

Ib tug kuj yuav nug, vim li cas lub xeev yuav hloov tsis tau? Yam khoom tsis muaj xeev los yog khoom nrog lub xeev tsis hloov tau muab kev lees paub thiab kev ntseeg siab rau txhua tog neeg siv nws. Hloov tsis tau cov khoom yog amplifying ib lub luag hauj lwm txoj cai vim hais tias ntawm kev xav tau ntawm dhau tag nrho cov dependencies mus rau lub constructor. Immutability blocks tej xeev hloov thaum lub sij hawm lub voj voog nyob.

Kuj Paub, vim li cas redux hloov tsis tau?

3 Teb. Redux yog ib lub tsev qiv ntawv me me uas sawv cev xeev raws li ( hloov tsis tau ) cov khoom. Thiab cov xeev tshiab los ntawm kev hla tam sim no xeev los ntawm kev ua haujlwm dawb huv los tsim cov khoom tshiab / daim ntawv thov lub xeev. Lawv yeej tsis hloov pauv, xa rov qab cov khoom tsim tshiab: Qhov no tso cai rau kev xav txog kev tawm tswv yim + tawm yam tsis muaj kev cuam tshuam.

Yog vim li cas immutability zoo?

Ib hloov tsis tau khoom yog ib qho uas nws lub xeev tsis tuaj yeem thiab yuav tsis hloov tom qab nws pib tsim. Hloov tsis tau Cov khoom zoo heev, feem ntau vim tias lawv yog Thread nyab xeeb (thiab threaded code yuav tsum zam kom ntau li ntau tau). Koj tuaj yeem hla lawv ib puag ncig yam tsis ntshai lawv yuav raug hloov.

Pom zoo: