Compare commits

...
2 Commits
Author SHA1 Message Date
semantic-release-bot c583287d00 chore(release): 4.0.1 [skip ci]
## [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))
2022-11-04 20:14:25 +00:00
BradByte b2f5f433ff fix: expose ref on ActionSheetProvider for statically invoking (#283)
This fixes an unknown breaking change from 4.0.0 where attempting to put a ref directly on `ActionSheetProvider` would error. For simplicity, the ref on that component will now return an object containing `showActionSheetWithOptions()`, but for backwards compatibility `getContext()` is also available.
2022-11-04 15:13:18 -05:00
4 changed files with 31 additions and 8 deletions

No files matched your search

+7
View File
@@ -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
View File
@@ -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",
+16 -7
View File
@@ -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>
);
}
});
+7
View File
@@ -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[];