March 2019
Intermediate to advanced
350 pages
7h 28m
English
Since there is no component instance, to use refs or event handlers with stateless functional components, you can define them in the following way:
() => {
let input;
const onClick = () => input.focus();
return (
<div>
<input ref={el => (input = el)} />
<button onClick={onClick}>Focus</button>
</div>
)
}
Read now
Unlock full access