-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
使用自定义的 useApiRequest hook 简化 app 中的请求处理逻辑
- Loading branch information
1 parent
5f6cc56
commit 3ac2b70
Showing
13 changed files
with
462 additions
and
649 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,16 @@ import { Stack } from 'expo-router'; | |
import { useColorScheme } from 'react-native'; | ||
import { SafeAreaView } from 'react-native-safe-area-context'; | ||
|
||
import { getApiV1CommonContributor } from '@/api/generate'; | ||
import ContributorsDOMComponent from '@/components/dom/contributors'; | ||
import useApiRequest from '@/hooks/useApiRequest'; | ||
|
||
// 这个页面更多地作为一种测试用途,用于展示 DOM 组件的使用 | ||
// 复杂的页面可以使用 DOM 组件来简化开发流程,毕竟相应的 Native 组件不太好做 | ||
// -- Baoshuo <[email protected]>, 2025-02-06 | ||
|
||
export default function Contributors() { | ||
const { data } = useApiRequest(getApiV1CommonContributor, {}); | ||
const colorScheme = useColorScheme(); | ||
|
||
return ( | ||
|
@@ -17,7 +20,7 @@ export default function Contributors() { | |
|
||
<SafeAreaView className="h-full w-full" edges={['bottom']}> | ||
{/* 在原生端传入 colorScheme,防止出现闪动 */} | ||
<ContributorsDOMComponent colorScheme={colorScheme} /> | ||
{data && <ContributorsDOMComponent data={data} colorScheme={colorScheme} />} | ||
</SafeAreaView> | ||
</> | ||
); | ||
|
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
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
Oops, something went wrong.