gpt4 book ai didi

javascript - 在 snack.expo.io 上 react native 使用 Hook

转载 作者:行者123 更新时间:2023-11-30 13:58:47 31 4
gpt4 key购买 nike

我想尝试在 snack.expo.io 上使用钩子(Hook),但它似乎不起作用。

有什么办法可以知道什么版本使用snack.expo?

最佳答案

如Expo Snacks网站右下角的@Dres,你可以更改expo版本,你可以选择最后一个,你就可以使用hooks。

查看示例:snack.expo.io/@abranhe/rn-hooks

import React, { useState } from 'react';
import { Text, View, Button, StyleSheet } from 'react-native';

export default () => {
const [count, setCount] = useState(0);

return (
<View style={{ flex: 1, justifyContent: 'space-around', alignItems: 'center'}}}>
<Text>You clicked {count} times</Text>
<Button onPress={() => setCount(count + 1)} title="Click me" />
</View>
);
};

关于javascript - 在 snack.expo.io 上 react native 使用 Hook ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56738123/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com