useImperativeHandle | React Hooks Tutorial #12

Pubblicato il: 14 aprile 2021
sul canale di: Philip Fabianek
6,218
187

In this final episode of my React Hooks Tutorial, we will learn about the useImperativeHandle hook. In order to understand the useImperativeHandle hook, we first have to understand the concept of forwarding refs using the React.forwardRef function. This allows us to pass refs to nested components, because we cannot achieve so using the ref keyword. After that, we will make use of the useImperativeHandle hook inside an input to modify the forwarded ref by exposing a custom focusAndBlur property. The useImperativeHandle hook will allow us to call that method from the parent component using a button.

Starting repository:

https://github.com/philipfabianek/rea...

Ending repository:

https://github.com/philipfabianek/rea...

Timestamps:

►0:00 Introduction
►0:26 Explaining forwaring refs
►1:09 Explaining the useImperativeHandle hook
►1:44 Creating input and the parent ref
►2:23 Forwarding the parent ref
►3:38 Implementing the useImperativeHandle hook
►5:10 Creating a button to call focusAndBlur on click
►5:45 Ending

Social Media:

►Twitter:   / philip_fabianek  
►LinkedIn:   / philip-fabianek  
►Website: http://www.philipfabianek.com
►GitHub: https://github.com/philipfabianek


In questa pagina del sito puoi guardare il video online useImperativeHandle | React Hooks Tutorial #12 della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Philip Fabianek 14 aprile 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 6,218 volte e gli è piaciuto 187 spettatori. Buona visione!