Skip to content

Commit e152119

Browse files
authored
Merge pull request #892 from thundersdata-frontend/rn-issue
feat: 优化多个组件
2 parents d3d2789 + 0648f3c commit e152119

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+452
-373
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.changeset/eleven-grapes-do.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@td-design/react-native-picker': minor
3+
---
4+
5+
fix: 优化代码

.changeset/famous-yaks-wash.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@td-design/react-native-rating': patch
3+
---
4+
5+
fix: 优化useEffect的依赖项

.changeset/healthy-spoons-trade.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@td-design/react-native': minor
3+
---
4+
5+
refactor: 优化多个组件

.changeset/hungry-tools-shop.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@td-design/react-native-picker': patch
3+
'@td-design/react-native-rating': patch
4+
'@td-design/rn-hooks': patch
5+
---
6+
7+
refactor: 优化代码性能

.changeset/proud-ads-pay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@td-design/react-native': minor
3+
---
4+
5+
refactor: 优化代码性能

.changeset/silver-eggs-press.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@td-design/rn-hooks': patch
3+
---
4+
5+
fix: 修复useCounter的bug

packages/hooks/src/useCounter/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { useState } from 'react';
1+
import { useEffect } from 'react';
22

33
import useMemoizedFn from '../useMemoizedFn';
4-
5-
// import useMemoizedFn from '../useMemoizedFn';
4+
import useSafeState from '../useSafeState';
65

76
type Options = { min?: number; max?: number };
87
export type ValueParam = number | ((c: number) => number);
@@ -14,7 +13,11 @@ export type ValueParam = number | ((c: number) => number);
1413
* @returns
1514
*/
1615
export default function useCounter(initialValue = 0, options: Options = {}) {
17-
const [current, setCurrent] = useState(() => getTargetValue(initialValue, options));
16+
const [current, setCurrent] = useSafeState(0);
17+
18+
useEffect(() => {
19+
setCurrent(getTargetValue(initialValue, options));
20+
}, [initialValue, options]);
1821

1922
const setValue = (value: ValueParam) => {
2023
setCurrent(c => {

packages/react-native-picker/src/date-picker/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const DatePicker = forwardRef<DatePickerRef, DatePickerProps>((props, ref) => {
6868

6969
if (displayType === 'modal') {
7070
return (
71-
<Modal visible={visible} onClose={handleClose} animationDuration={0}>
71+
<Modal position="bottom" animationType="slide" visible={visible} onClose={handleClose}>
7272
<Flex
7373
borderBottomWidth={ONE_PIXEL}
7474
borderBottomColor="border"

packages/react-native-picker/src/picker/components/Cascade/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function Cascader<T>({
5353

5454
if (displayType === 'modal') {
5555
return (
56-
<Modal visible={visible} onClose={onClose} animationDuration={0}>
56+
<Modal position="bottom" animationType="slide" visible={visible} onClose={onClose}>
5757
<Flex
5858
borderBottomWidth={ONE_PIXEL}
5959
borderBottomColor="border"

0 commit comments

Comments
 (0)