-
-
Save reime005/86ff3a905b1eef5a359259d4e321c511 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect } from 'react'; | |
import { View, Text, Button } from 'react-native'; | |
export const Example = () => { | |
const [foo, setFoo] = useState(30); | |
useEffect(() => { | |
if (foo >= 42) { | |
setFoo(42); | |
} | |
}, [foo]) | |
return ( | |
<view> | |
<text>Foo is {foo}.</text> | |
<button onpress={() => setFoo(foo + 1)} title='Increase Foo!' /> | |
</view> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment