Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6212

How can i filter an state array in functional component in react native

$
0
0

enter image description hereI have an defined an array as state variable in a functional component

const [MessageResultsFirebase, setMessagesFirebase] = useState<MessageCellPropsFirebase[]>();

I want to filter it using Array.filter function to update the list.

var filterResult: MessageCellPropsFirebase = MessageResultsFirebase?.filter((element, index, array)=>{       return (element.key == snapshot.key);     });

but it gives the error "cannot find property filter of undefined". P.S: console.log(MessageResultsFirebase);works in same context.Please help i am new with these.


Viewing all articles
Browse latest Browse all 6212

Trending Articles



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