简体   繁体   中英

Trigger an on screen keyboard on windows using react native

I am using a windows device with a touch screen, I would like for an input field that I have to open the on-screen windows keyboard, is there a way to do that in react native for windows?

You can initiate focus on component mount. Give a ref to TextInput using useRef() .

const ref = useRef<TextInput|null>(null); // If you are using typescript

// If not then just 
// const ref = useRef();

React.useEffect(() => {
  ref.current?.focus();
}, []);

<TextInput ref={ref} {...otherProps} />;


The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM