May 2019
Intermediate to advanced
496 pages
10h 38m
English
The user of our application will, most of the time, be typing in the prompt at the bottom-right of the screen. It would be a great help to them if they could see the cursor already positioned there. We should do this after launching the app for the first time, and when another element—such as the name text field or the menu buttons—steals focus.
React doesn't support setting focus, so we need to use a ref on our components and then drop into the DOM API.
We'll do this via a Redux reducer. It will have two actions: PROMPT_FOCUS_REQUEST and PROMPT_HAS_FOCUSED. Any of the React components in our application will be able to dispatch the first action. The Prompt component will "listen" ...
Read now
Unlock full access