ComponentWillUpdate yog dab tsi?
ComponentWillUpdate yog dab tsi?

Video: ComponentWillUpdate yog dab tsi?

Video: ComponentWillUpdate yog dab tsi?
Video: What Is AI? | Artificial Intelligence | What is Artificial Intelligence? | AI In 5 Mins |Simplilearn 2024, Kaum ib hlis
Anonim

Cov componentWillUpdate () yog lub caij nyoog rau peb los daws cov kev hloov pauv thiab npaj rau qhov kev tshwm sim tom ntej. Yog tias peb xav nkag mus rau cov khoom qub lossis lub xeev, peb tuaj yeem hu rau qhov no. props los yog qhov no. xeev. Tom qab ntawd peb tuaj yeem sib piv lawv rau cov txiaj ntsig tshiab thiab hloov pauv / suav raws li xav tau.

Raws li txoj cai, thaum twg kuv yuav tsum siv cov khoom yuav hloov tshiab?

1 Teb. Cov componentWillUpdate muab rau koj tswj kom tswj cov khoom ua ntej nws tau txais cov khoom tshiab lossis lub xeev. Kuv feem ntau siv nws ua animations. Cia peb hais tias, Kuv xav kom smoothly ploj ib lub caij tawm ntawm qhov pom, ua ntej tshem tawm lub dom.

Ib yam li ntawd, qhov kev siv ntawm componentWillUnmount yog dab tsi? componentWillUnmount yog qhov kawg ua haujlwm raug hu tam sim ua ntej cov khoom raug tshem tawm ntawm DOM. Nws yog feem ntau siv los ua kom huv si rau ib qho DOM-cov ntsiab lus lossis cov sijhawm tsim hauv componentWillMount. Hauv picnic, componentWillUnmount sib raug rau ua ntej koj tuaj tos koj daim pam picnic.

Tsis tas li ntawd, componentDidUpdate yog dab tsi?

componentDidUpdate () yog hu ua tom qab componentDidMount() thiab ua tau yuav pab tau ua qee qhov kev txiav txim thaum lub xeev hloov. componentDidUpdate () siv raws li nws thawj ob qhov kev sib cav cov khoom yav dhau los thiab lub xeev dhau los. Hauv txoj kev peb ua tau xyuas seb puas muaj mob yog ntsib thiab ua ib qho kev ua raws li nws.

ComponentWillReceiveProps yog dab tsi?

63. 1) componentWillReceiveProps hu ua ua ntej componentWillUpdate hauv React's update lifecycle. Koj hais yog lawm os componentWillReceiveProps tso cai rau koj hu rau setState. Ntawm qhov tod tes, ComponentWillUpdate yog hu rov qab los siv thaum koj xav tau los teb rau lub xeev hloov.

Pom zoo: