我正在嘗試創建一個待辦事項列表應用程序,帶有一個共享按鈕,可以共享您擁有的待辦事項列表。該應用程序已基本完成,我認為代碼的其他部分是無關緊要的,但如果需要,我可以發布它們。我的狀態是這樣的:const [todos, setTodos] = useState([ {todo: 'Add a todo', key: '1'}, ]);我的分享功能是這樣的 -直接取自官方文檔-: const onShare = async () => { try { const result = await Share.share({ message: todos.todo }); if (result.action === Share.sharedAction) { if (result.activityType) { // shared with activity type of result.activityType } else { // shared } } else if (result.action === Share.dismissedAction) { // dismissed } } catch (error) { alert(error.message); } };我在其中渲染按鈕并調用函數:<Button color= 'orange' title={'Share'} onPress={onShare}/>我的問題出在部分(第二個代碼塊)中,我無法聯系到該州內的message:個人。這可能是最簡單的問題,但我找不到方法......todotodos請幫助 :)
React Native 掛鉤使用多個對象
HUWWW
2023-07-20 11:03:53