简体   繁体   中英

How to click a button on a different page in React Native?

If I'm on page 2 and I want to click a button on Homepage, how do I do it?

In Javascript, we can just do query selector and DOM manipulation but that functionality doesn't exist in React Native

You can achieve this by sending and receiving events.

Using event bus you can fire some events from screen A and receive/catch those events in screen B. While you receive those events, perform the functionality which you want.

This is the least code correct implementation which you need.

Also, please dont remove the event in componentDidUnmount

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