[v4] BottomSheetModal Hides after parent state changed inside modal
See original GitHub issueBug
When changing screen state inside “BottomSheetModal” where i pass “React.Dispatch” prop will hide bottom sheet modal content, until i click somewhere then it will show again
this happends only on Expo 44, Expo 43 works perfect
PS unable to make stack cuz Expo 44 is not yet in Stack …
Environment info
Library | Version |
---|---|
@gorhom/bottom-sheet | ^4.1.5 |
react-native | 0.64.3 |
react-native-reanimated | ~2.3.1 |
react-native-gesture-handler | ~2.1.0 |
expo | ~44.0.0 |
Video
Steps To Reproduce
- Change parent state from modal
Describe what you expected to happen:
- when i change parent / state outside of modal modal should not hidde
Reproducible sample code
Parent ( drawer screen )
const [filter, setFilter] = React.useState({
dlc: {
2: true,
3: true,
4: false,
5: true,
6: true,
}
});
const [showFilter, setShowFilter] = React.useState<boolean>(false);
return <BottomSheetModalWrap filter={filter} setFilter={setFilter} visible={showFilter} setVisible={setShowFilter} />
BottomSheetWrap component
interface bottomSheetModalWrapProps {
visible: boolean
setVisible: React.Dispatch<boolean>
filter: any // yup any for example ...
setFilter: Dispatch<any> // yup any for example ...
}
const BottomSheetModalWrap: React.FC<BottomSheetModalWrapProps> = (props) => {
const bottomSheetModalRef = useRef<BottomSheetModal>(null);
React.useEffect(() => {
if (props.visible) {
bottomSheetModalRef.current?.present();
} else {
bottomSheetModalRef.current?.dismiss();
}
}, [props.visible]);
function setNewSwitchValue(dlc: number, switchValue: boolean) {
let newFilter = JSON.parse(JSON.stringify(props.filter));
newFilter.dlc[dlc] = switchValue;
props.setFilter(newFilter);
}
return (
<BottomSheetModal
ref={bottomSheetModalRef}
snapPoints={['75%']}
backdropComponent={props => (
<BottomSheetBackdrop
{...props}
disappearsOnIndex={-1}
appearsOnIndex={0}
/>
)}
onDismiss={() => props.setVisible(false)}
>
<View>
<View style={{flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between'}}>
<Text>A Realm Reborn</Text>
<Switch
ios_backgroundColor="#3e3e3e"
value={props.filter.dlc[2]}
onValueChange={(switchValue) => setNewSwitchValue(2, switchValue)}
/>
</View>
</View>
</BottomSheetModal>
)
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:15
- Comments:36 (2 by maintainers)
Top Results From Across the Web
Bottom Sheet Modal: Dynamic height on state change doesn't ...
The useState effect works fine. The elements get hidden/shown in perfect speed . But, the height of the modal doesnt re-render/re-calculate ...
Read more >ion-modal: Ionic Mobile App Custom Modal API Component
ion-modal is a dialog that appears on top of mobile app content, and must be dismissed before interaction resumes. Learn more about custom...
Read more >Jetpack Compose bottom sheet over Android view using ...
, which focuses on BottomSheetScaffold . In our example, we chose ModalBottomSheetLayout since it enables us to get a state change by tapping...
Read more >showModalBottomSheet function - material library - Dart API
This example demonstrates how to use showModalBottomSheet to display a bottom sheet that obscures the content behind it when a user taps a...
Read more >Props | React Native Bottom Sheet - GitHub Pages
Initial snap index. You also could provide -1 to initiate bottom sheet in closed state. type, default, required. number ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
At all. It is finally fixed. You need to upgrade
react-native-reanimated
to v2.5.0.@hirbod Thanks for all your work and diligence staying up on this issue. I also saw your involvement in the root cause bug in
react-native-reanimated
. Do you have thoughts on when the root cause fix will be merged?Thanks all for your work here 👍