react-native-modalbox icon indicating copy to clipboard operation
react-native-modalbox copied to clipboard

issues with refs in React Native 0.61

Open Michaelvons opened this issue 6 years ago • 2 comments

The fix is to make use of react-native hooks

import the UseRef Hook import React, {useRef} from 'react';

create a variable using it const modal3 = useRef();

in the Modal prop, refer to the ref

<Modal
ref={modal3}>
...
</Modal>

Open your modal using the open() Method like so:

<Button
title="Open Modal"
onPress={() => modal3.current.open()}
 /> 

voila !!. It works

Michaelvons avatar Jan 10 '20 10:01 Michaelvons

This doesn't work!

Infinitism avatar Oct 23 '20 14:10 Infinitism

@Infinitism Kindly share your code

Michaelvons avatar Oct 23 '20 21:10 Michaelvons