【发布时间】:2021-08-20 00:10:24
【问题描述】:
当前尝试设置 react-native-action-sheet 并获得无效的钩子调用
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
我按照示例包装了我的wrapped your top-level component with even when using hooks。
export default () => (
<ActionSheetProvider>>
<App />
</<ActionSheetProvider>>
);
想知道这是否是我设置的方式:
import { Linking } from 'react-native';
import { useActionSheet } from '@expo/react-native-action-sheet';
export const SideButton = () => {
const { showActionSheetWithOptions } = useActionSheet();
const cancelButtonIndex = 1;
const options = ['Email', 'Cancel'];
const title = 'Email Me';
const message = 'Let me know your issues';
return showActionSheetWithOptions(
{
options,
cancelButtonIndex,
title,
message,
},
(buttonIndex) => {
if (buttonIndex === 0) {
Linking.openURL('mailto:_____').catch();
} else {
return;
}
}
);
};
甚至我在这里如何称呼它:
import { Linking, Text, TouchableOpacity, View } from 'react-native';
import { SideButton } from './utils/HelpPopUp';
const ButtonContainer = () => (
<TouchableOpacity>
<Text onPress={() => Linking.openURL('_MY_WEBSITE_').catch()}>Checkout my stuff</Text>
</TouchableOpacity>
);
const Menu = (props) => {
return (
<View>
<ButtonContainer />
</View>
);
};
export default Menu;
【问题讨论】:
标签: reactjs react-native react-hooks expo