@maymie
В React Native можно обратиться к элементу, используя уникальный ref
. Вы можете создать ссылку на элемент и затем использовать ее, чтобы получить доступ к элементу. Например:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import React, { useRef } from 'react'; import { TextInput } from 'react-native'; const Input = () => { const inputRef = useRef(null); const focusInput = () => { inputRef.current.focus(); }; return ( <TextInput ref={inputRef} onFocus={focusInput} /> ); }; export default Input; |