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

How to use useEffect inside a View in React Native

$
0
0

I want to use an useEffect inside a return (inside a Text that is inside multiple View to be exact) and from what I know, I must use {...} in order to say that what I write is some code. Howether I got a blank screen without errors and I don't know where is the issue with my code.Here is the code:

const [pass, setPass] = useState(0);... return (<View><FlatList                    data={letter.description}                    numColumns={2}                    keyExtractor={(_, index) => index.toString()}                    renderItem={({ item }) => {                      if (pass >= letter.description?.length) {                        useEffect(() => {                          setPass((prev) => 0);                        });                      }                      return (<View><Text>                            {letter.data[pass]}                            {"\n"}</Text><Text>                            {letter.description[pass]}                            {useEffect(() => {                              setPass((prev) => prev + 1);                            })}                            {"\n"}</Text></View>                      );                    }}                  /></View>

letter is my data, but you can ignore it. I just keep it here to explain why I need the pass


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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