STATE_HIDDEN not working
STATE_HIDDEN renders the same view as STATE_COLLAPSED. `<CoordinatorLayout style={{flex: 1}}> <View style={{ flex: 1, backgroundColor: 'transparent' }}></View> <BottomSheetBehavior
ref='bottomSheet'
peekHeight={70}
hideable={true}
state={BottomSheetBehavior.STATE_HIDDEN}>
<View style={{backgroundColor: '#4389f2'}}>
<View style={{padding: 26}}>
<Text>BottomSheetBehavior!</Text>
</View>
<View style={{height: 200, backgroundColor: '#fff'}} />
</View>
</BottomSheetBehavior>
<FloatingActionButton autoAnchor ref="fab" />
</CoordinatorLayout>`
Hi, Thanks for report.
There's a issue with the @ReactProps order, it setting the state before checking the hideable prop as true, i am still trying to figure out.
But you can set the STATE_HIDDEN on the componentDidMount as follows
componentDidMount() {
this.bottomSheet.setBottomSheetState(BottomSheetBehavior.STATE_HIDDEN)
}
render() {
<BottomSheetBehavior ref={ref => {this.bottomSheet = ref}}></BottomSheetBehavior>
}
I also do not recommend you manage the bottom sheet state directly on the state prop, because it's hard to control, you should manage with the setBottomSheetState method.
Thanks for the information!
this.bottomSheet.setBottomSheetState(BottomSheetBehavior.STATE_HIDDEN)
Should it work to hide a sheet programmatically?
I think im doing something wrong
@mikeevstropov did you enabled hideable={true}?
@cesardeazevedo Yes. But im using NestedScrollView
hideBottomSheet() {
if (this.bottomSheet)
this.bottomSheet.setBottomSheetState(
BottomSheetBehavior.STATE_HIDDEN
)
}
<BottomSheetBehavior
hideable={true}
peekHeight={110}
ref={ref => this.bottomSheet = ref}>
<NestedScrollView ref={ref => this.nestedScroll = ref}>
{ child }
</NestedScrollView>
</BottomSheetBehavior>
@cesardeazevedo Im sorry. Its my mistake. Method works correctly.