Quantcast
Channel: Active questions tagged touchablewithoutfeedback - Stack Overflow
Viewing all articles
Browse latest Browse all 46

React native useRef Hook wouldn't store an array

$
0
0

Here's a simple code that doesn't work I really don't know why

const myArray = useRef(null) // or const myArray = useRef([]) or const myArray = useRef(new Array())...Inside the functional component<TouchableWithoutFeedBack onPress={()=>{ myArray.current = [5, 6]; console.log(myArray.current);}}> <View><Text>some text<Text></View></TouchableWithoutFeedBack>

The result of the console log is 1 wathever I put in the array and wathever the way I initialyse the useRef. It works fine for not array variables and I didn't try it with objects.

Thanks for your help.


Viewing all articles
Browse latest Browse all 46

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>