chore: Bump reanimated requirements (#149)

* Bump the reanimated requirement to 2.2.0 and above

* bump versions podfile

* Simplify Frame Processor

* Add `'worklet'` note
This commit is contained in:
Marc Rousavy
2021-05-27 11:08:57 +02:00
committed by GitHub
parent a721f86c75
commit deb8beb688
10 changed files with 35 additions and 40 deletions

View File

@@ -336,7 +336,7 @@ export class Camera extends React.PureComponent<CameraProps> {
private assertFrameProcessorsEnabled(): void {
// @ts-expect-error JSI functions aren't typed
if (global.setFrameProcessor == null || global.unsetFrameProcessor == null)
throw new Error('Frame Processors are not enabled. Make sure you install react-native-reanimated 2.1.0 or above!');
throw new Error('Frame Processors are not enabled. Make sure you install react-native-reanimated 2.2.0 or above!');
}
/**

View File

@@ -1,10 +1,12 @@
import { DependencyList, useCallback } from 'react';
import type { Frame } from 'src/Frame';
type FrameProcessor = (frame: Frame) => void;
/**
* Returns a memoized Frame Processor function wich you can pass to the `<Camera>`. (See ["Frame Processors"](https://cuvent.github.io/react-native-vision-camera/docs/guides/frame-processors))
*
* > If you are using the [react-hooks ESLint plugin](https://www.npmjs.com/package/eslint-plugin-react-hooks), make sure to add `useFrameProcessor` to `additionalHooks` inside your ESLint config. (See ["advanced configuration"](https://www.npmjs.com/package/eslint-plugin-react-hooks#advanced-configuration))
* Make sure to add the `'worklet'` directive to the top of the Frame Processor function, otherwise it will not get compiled into a worklet.
*
* @param frameProcessor The Frame Processor
* @param dependencies The React dependencies which will be copied into the VisionCamera JS-Runtime.
@@ -18,10 +20,4 @@ import type { Frame } from 'src/Frame';
* }, [])
* ```
*/
export function useFrameProcessor(frameProcessor: (frame: Frame) => void, dependencies: DependencyList): (frame: Frame) => void {
return useCallback((frame: Frame) => {
'worklet';
return frameProcessor(frame);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, dependencies);
}
export const useFrameProcessor: (frameProcessor: FrameProcessor, dependencies: DependencyList) => FrameProcessor = useCallback;