Skip to content

Commit 597fdb8

Browse files
ChenlingasMxhy
authored andcommitted
fix: 配置exmaple入口模式判断
1 parent 072cf9f commit 597fdb8

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

example/examples/src/App.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from 'react';
2+
import {useColorScheme} from 'react-native';
23
import {NavigationContainer} from '@react-navigation/native';
34
import {createStackNavigator} from '@react-navigation/stack';
45
import {SafeAreaView, StatusBar, StyleSheet} from 'react-native';
56
import {RootSiblingParent} from 'react-native-root-siblings';
6-
import {ThemeProvider} from '@uiw/react-native';
7-
7+
import {ThemeProvider, theme} from '@uiw/react-native';
88
import {stackPageData} from './routes';
99

1010
const Stack = createStackNavigator();
@@ -16,11 +16,13 @@ const styles = StyleSheet.create({
1616
});
1717

1818
const App = () => {
19+
const colorScheme = useColorScheme();
20+
console.log('colorScheme', colorScheme);
1921
return (
2022
<RootSiblingParent>
2123
<SafeAreaView style={styles.block}>
2224
<StatusBar barStyle="dark-content" />
23-
<ThemeProvider>
25+
<ThemeProvider theme={colorScheme === 'light' ? {...theme.lightTheme} : {...theme.darkTheme}}>
2426
<NavigationContainer>
2527
<Stack.Navigator initialRouteName="Home">
2628
<Stack.Screen

packages/core/src/DatePicker/components/date-picker/useDatePicker.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useMemo } from 'react';
2+
import { usePersistFn } from 'ahooks';
23
import dayjs, { Dayjs } from 'dayjs';
34
import { ItemValue } from '../../../Picker/components/WheelPicker/type';
45
import { CascadePickerItemProps, DatePickerPropsBase } from './type';
@@ -319,8 +320,8 @@ export default function useDatePicker({
319320
};
320321

321322
return {
322-
getValueCols: getValueCols,
323-
onValueChange: onValueChange,
323+
getValueCols: usePersistFn(getValueCols),
324+
onValueChange: usePersistFn(onValueChange),
324325
};
325326
}
326327

packages/core/src/DatePicker/useDatePicker.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
import { useEffect, useRef } from 'react';
1+
import { useEffect } from 'react';
22
import { BackHandler } from 'react-native';
3-
import { useSafeState } from 'ahooks';
3+
import { useSafeState, usePersistFn } from 'ahooks';
4+
import { useLatest } from '../utils/hooks';
45
import dayjs from 'dayjs';
56
import { DatePickerPropsBase, ModalPickerProps } from './components/date-picker/type';
67

7-
function useLatest<T>(value: T) {
8-
const ref = useRef<T>(value);
9-
ref.current = value;
10-
11-
return ref;
12-
}
13-
148
export default function useDatePicker({
159
onClosed,
1610
onChange,
@@ -52,8 +46,8 @@ export default function useDatePicker({
5246

5347
return {
5448
date,
55-
handleChange: handleChange,
56-
handleOk: handleOk,
57-
handleClose: handleClose,
49+
handleChange: usePersistFn(handleChange),
50+
handleOk: usePersistFn(handleOk),
51+
handleClose: usePersistFn(handleClose),
5852
};
5953
}

packages/core/src/utils/hooks.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,10 @@ export function usePropsValue<T>(options: Options<T>) {
4747
});
4848
return [stateRef.current, setState] as const;
4949
}
50+
51+
export function useLatest<T>(value: T) {
52+
const ref = useRef<T>(value);
53+
ref.current = value;
54+
55+
return ref;
56+
}

0 commit comments

Comments
 (0)