snack.expo.io 上的 React 本机使用挂钩
React native use hooks on snack.expo.io
我想尝试在 snack.expo.io 上使用挂钩,但它似乎不起作用。
有没有办法知道snack.expo使用的是什么版本?
屏幕右下方显示 Expo v33.0.0
,您可以将其更改为 32 或 31。
Expo Blog 显示哪个版本的 Expo 使用哪个版本的 React Native。所以 Expo 33 使用 RN 0.59.8,其中包括钩子。所以它应该有效。
如世博小吃官网右下角的@Dres,可以换世博版本,可以select最后一个,就可以使用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>
);
};
我想尝试在 snack.expo.io 上使用挂钩,但它似乎不起作用。
有没有办法知道snack.expo使用的是什么版本?
屏幕右下方显示 Expo v33.0.0
,您可以将其更改为 32 或 31。
Expo Blog 显示哪个版本的 Expo 使用哪个版本的 React Native。所以 Expo 33 使用 RN 0.59.8,其中包括钩子。所以它应该有效。
如世博小吃官网右下角的@Dres,可以换世博版本,可以select最后一个,就可以使用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>
);
};