我正在使用react native开发应用程序。我有一个父组件“ RootComponent”和一个“ ChildComponent”嵌套在父组件中。使用条件渲染来渲染ChildComponent中渲染的内容。 ChildComponent根据RootComponent的状态呈现3个不同的视图。 现在,我要实现的是当用户在RootComponent中的ChildComponent外部点击时,将ChildComponent的视图重置为默认视图。我该如何实现?
我尝试了什么?
我在RootComponent中使用了TouchableNativeFeedback,并使用onPress将状态设置为默认状态。这可行,但是当用户在ChildComponent内部点击时,它也将状态更改为默认状态。
Thread.sleep(...)