Breaking Change: makeImageFromView API incompatibility between versions 1.90 and 1.10.1 #2902
Description
Description
There's a breaking change in the API for capturing canvas snapshots between @shopify/react-native-skia versions 1.90 and 1.10.1. The makeImageFromView function used in v1.90 no longer works in v1.10.1, and needs to be replaced with viewRef.current.makeImageSnapshot().
This causes runtime errors for applications that upgrade from v1.90 to v1.10.1 without updating their code.
Current Behavior
In version 1.90:
const snapshot = await makeImageFromView(viewRef);
works correctly.
In version 1.10.1:
The above code throws the following error:
Error: Argument appears to not be a ReactComponent. Keys: makeImageSnapshot,makeImageSnapshotAsync,redraw,getNativeId
- Must use viewRef.current.makeImageSnapshot() instead
React Native Skia Version
1.10.1
React Native Version
0.76.6
Using New Architecture
- Enabled
Steps to Reproduce
Create a React Native project with @shopify/react-native-skia v1.90
Implement canvas snapshot functionality using makeImageFromView
Upgrade @shopify/react-native-skia to version 1.10.1
Try to capture canvas snapshot
Snack, Code Example, Screenshot, or Link to Repository
// Working in v1.90
import { makeImageFromView } from '@shopify/react-native-skia';
const getSignature = async () => {
const snapshot = await makeImageFromView(viewRef);
const imageData = snapshot.encodeToBase64();
};
// Required for v1.10.1
const getSignature = async () => {
const snapshot = await viewRef.current.makeImageSnapshot();
const imageData = snapshot.encodeToBase64();
};