Skip to content

Commit

Permalink
fix(onlayout): fix onlayout trigger on text change
Browse files Browse the repository at this point in the history
  • Loading branch information
EQuimper committed May 14, 2024
1 parent 28f5b8d commit ef288f9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/ViewWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const ViewWrapper = ({ name, style, children }: Props) => {
<View
ref={ref}
style={style}
onLayout={() => {
onLayout={({ nativeEvent }) => {
const element = state[name];
if (mainViewRef && !state[name]) {
ref.current?.measureLayout(mainViewRef, (_, y, _w, h) => {
setState((s) => ({
Expand All @@ -34,6 +35,14 @@ const ViewWrapper = ({ name, style, children }: Props) => {
},
}));
});
} else if (element) {
setState({
...state,
[name]: {
...element,
height: nativeEvent.layout.height,
},
});
}
}}
>
Expand Down

0 comments on commit ef288f9

Please sign in to comment.