Skip to main content

Global Methods

TrueSheet relies heavily on component methods to present and dismiss the sheet. However, this becomes challenging when the button is deep within the component tree.

To resolve this issue, TrueSheet provides global methods that allow you to present or dismiss any sheet from anywhere!

How?

Somewhere in your App, define the sheet with a name.

const App = () => {
return (
<TrueSheet name="my-sheet">
<View />
</TrueSheet>
)
}

In your component, present the sheet using the present global method.

import { TrueSheet } from '@lodev09/react-native-true-sheet'

const SomeComponent = () => {
const presentMySheet = () => {
TrueSheet.present('my-sheet') // 🎉
}

return (
<Button onPress={presentMySheet} title="Present My Sheet" />
)
}

Guess what? You can also dismiss it globally 🤩.

TrueSheet.dismiss('my-sheet') // ✅