mirror of
https://github.com/expo/react-native-action-sheet.git
synced 2026-11-15 09:18:06 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c583287d00 | ||
|
|
b2f5f433ff |
No files matched your search
@@ -1,5 +1,12 @@
|
||||
# Changelog
|
||||
|
||||
## [4.0.1](https://github.com/expo/react-native-action-sheet/compare/v4.0.0...v4.0.1) (2022-11-04)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* expose ref on ActionSheetProvider for statically invoking ([#283](https://github.com/expo/react-native-action-sheet/issues/283)) ([b2f5f43](https://github.com/expo/react-native-action-sheet/commit/b2f5f433ff2070c77fdd62b273d2d80e636efd3a))
|
||||
|
||||
# [4.0.0](https://github.com/expo/react-native-action-sheet/compare/v3.14.0...v4.0.0) (2022-10-26)
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@expo/react-native-action-sheet",
|
||||
"version": "4.0.0",
|
||||
"version": "4.0.1",
|
||||
"description": "A cross-platform ActionSheet for React Native",
|
||||
"react-native": "lib/module/index.js",
|
||||
"types": "lib/typescript/index.d.ts",
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as React from 'react';
|
||||
import NativeActionSheet from './ActionSheet';
|
||||
import CustomActionSheet from './ActionSheet/CustomActionSheet';
|
||||
import { Provider } from './context';
|
||||
import { ActionSheetOptions } from './types';
|
||||
import { ActionSheetOptions, ActionSheetProviderRef } from './types';
|
||||
|
||||
interface Props {
|
||||
children: React.ReactNode;
|
||||
@@ -12,11 +12,10 @@ interface Props {
|
||||
useCustomActionSheet?: boolean;
|
||||
}
|
||||
|
||||
export default function ActionSheetProvider({
|
||||
children,
|
||||
useNativeDriver,
|
||||
useCustomActionSheet = false,
|
||||
}: Props) {
|
||||
export default React.forwardRef<ActionSheetProviderRef, Props>(function ActionSheetProvider(
|
||||
{ children, useNativeDriver, useCustomActionSheet = false },
|
||||
ref
|
||||
) {
|
||||
const actionSheetRef = React.useRef<NativeActionSheet>(null);
|
||||
|
||||
const context = React.useMemo(
|
||||
@@ -30,6 +29,16 @@ export default function ActionSheetProvider({
|
||||
[actionSheetRef]
|
||||
);
|
||||
|
||||
React.useImperativeHandle(
|
||||
ref,
|
||||
() => ({
|
||||
// backwards compatible with 13.x before context was being passed right on the ref
|
||||
getContext: () => context,
|
||||
showActionSheetWithOptions: context.showActionSheetWithOptions,
|
||||
}),
|
||||
[context]
|
||||
);
|
||||
|
||||
const ActionSheet = React.useMemo(
|
||||
() => (useCustomActionSheet ? CustomActionSheet : NativeActionSheet),
|
||||
[useCustomActionSheet]
|
||||
@@ -42,4 +51,4 @@ export default function ActionSheetProvider({
|
||||
</ActionSheet>
|
||||
</Provider>
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -8,6 +8,13 @@ export interface ActionSheetProps {
|
||||
) => void;
|
||||
}
|
||||
|
||||
export interface ActionSheetProviderRef extends ActionSheetProps {
|
||||
/**
|
||||
* @deprecated Simply call `showActionSheetWithOptions()` directly from the ref now
|
||||
*/
|
||||
getContext: () => ActionSheetProps;
|
||||
}
|
||||
|
||||
// for iOS
|
||||
export interface ActionSheetIOSOptions {
|
||||
options: string[];
|
||||
|
||||
Reference in new issue
Block a user