Skip to content

Commit

Permalink
fix: 配置exmaple入口模式判断
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenlingasMx authored and hy committed Apr 8, 2023
1 parent 072cf9f commit 597fdb8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
8 changes: 5 additions & 3 deletions example/examples/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';
import {useColorScheme} from 'react-native';
import {NavigationContainer} from '@react-navigation/native';
import {createStackNavigator} from '@react-navigation/stack';
import {SafeAreaView, StatusBar, StyleSheet} from 'react-native';
import {RootSiblingParent} from 'react-native-root-siblings';
import {ThemeProvider} from '@uiw/react-native';

import {ThemeProvider, theme} from '@uiw/react-native';
import {stackPageData} from './routes';

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

const App = () => {
const colorScheme = useColorScheme();
console.log('colorScheme', colorScheme);
return (
<RootSiblingParent>
<SafeAreaView style={styles.block}>
<StatusBar barStyle="dark-content" />
<ThemeProvider>
<ThemeProvider theme={colorScheme === 'light' ? {...theme.lightTheme} : {...theme.darkTheme}}>
<NavigationContainer>
<Stack.Navigator initialRouteName="Home">
<Stack.Screen
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useMemo } from 'react';
import { usePersistFn } from 'ahooks';
import dayjs, { Dayjs } from 'dayjs';
import { ItemValue } from '../../../Picker/components/WheelPicker/type';
import { CascadePickerItemProps, DatePickerPropsBase } from './type';
Expand Down Expand Up @@ -319,8 +320,8 @@ export default function useDatePicker({
};

return {
getValueCols: getValueCols,
onValueChange: onValueChange,
getValueCols: usePersistFn(getValueCols),
onValueChange: usePersistFn(onValueChange),
};
}

Expand Down
18 changes: 6 additions & 12 deletions packages/core/src/DatePicker/useDatePicker.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import { useEffect, useRef } from 'react';
import { useEffect } from 'react';
import { BackHandler } from 'react-native';
import { useSafeState } from 'ahooks';
import { useSafeState, usePersistFn } from 'ahooks';
import { useLatest } from '../utils/hooks';
import dayjs from 'dayjs';
import { DatePickerPropsBase, ModalPickerProps } from './components/date-picker/type';

function useLatest<T>(value: T) {
const ref = useRef<T>(value);
ref.current = value;

return ref;
}

export default function useDatePicker({
onClosed,
onChange,
Expand Down Expand Up @@ -52,8 +46,8 @@ export default function useDatePicker({

return {
date,
handleChange: handleChange,
handleOk: handleOk,
handleClose: handleClose,
handleChange: usePersistFn(handleChange),
handleOk: usePersistFn(handleOk),
handleClose: usePersistFn(handleClose),
};
}
7 changes: 7 additions & 0 deletions packages/core/src/utils/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,10 @@ export function usePropsValue<T>(options: Options<T>) {
});
return [stateRef.current, setState] as const;
}

export function useLatest<T>(value: T) {
const ref = useRef<T>(value);
ref.current = value;

return ref;
}

0 comments on commit 597fdb8

Please sign in to comment.