Skip to content

Commit 7e5a01b

Browse files
committed
fix(Modal): 修复Modal卡死
1 parent 0f6fd44 commit 7e5a01b

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

example/examples/src/routes/DatePicker/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export default class BadgeView extends React.Component<BadgeViewProps> {
3030
onOk={() => this.setState({visible: false})}
3131
onClosed={() => this.setState({visible: false})}
3232
precision="second"
33-
max="2021-11-30 23:50:50"
3433
/>
3534
</Body>
3635
<Footer />

packages/core/src/Modal/index.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, { useState, useMemo, useRef, useLayoutEffect } from 'react';
2-
import { Animated, StyleSheet, LayoutChangeEvent, Dimensions, ViewStyle, LayoutAnimation } from 'react-native';
1+
import React, { useState, useMemo, useRef } from 'react';
2+
import { Animated, StyleSheet, LayoutChangeEvent, Dimensions, ViewStyle } from 'react-native';
33
import MaskLayer, { MaskLayerProps } from '../MaskLayer';
44

55
let MainWidth = Dimensions.get('window').width;
@@ -23,9 +23,7 @@ const Modal = (props: ModalProps = {}) => {
2323
function onDismiss() {
2424
onClosed && onClosed();
2525
}
26-
2726
function measureContainer(event: LayoutChangeEvent) {
28-
LayoutAnimation.linear(); //加入该函数进行布局平滑过渡动画
2927
const { height, width } = event.nativeEvent.layout;
3028
if (!layoutHeight && isVertical) {
3129
setLayoutHeight(height);
@@ -35,7 +33,7 @@ const Modal = (props: ModalProps = {}) => {
3533
}
3634
}
3735

38-
useLayoutEffect(() => {
36+
useMemo(() => {
3937
function getTransformSize() {
4038
if (placement === 'top') {
4139
return -layoutHeight;
@@ -110,7 +108,6 @@ const Modal = (props: ModalProps = {}) => {
110108
</Animated.View>
111109
</Animated.View>
112110
);
113-
114111
return (
115112
<MaskLayer {...otherProps} visible={visible} onDismiss={onDismiss}>
116113
{child}

0 commit comments

Comments
 (0)