Skip to content

Commit

Permalink
Merge branch 'main' into wcandillon-patch-52
Browse files Browse the repository at this point in the history
  • Loading branch information
wcandillon authored Dec 18, 2024
2 parents 0226cd7 + cca99c4 commit 0e4e74f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 34 deletions.
33 changes: 0 additions & 33 deletions apps/docs/docs/canvas/contexts.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,6 @@ However, if you need to use a React context within your drawing, you must re-inj

We found [its-fine](https://github.com/pmndrs/its-fine), also used by [react-three-fiber](https://github.com/pmndrs/react-three-fiber), to provide an elegant solution to this problem.

## Manual Context Injection

```tsx twoslash
import React from "react";
import { Canvas, Fill } from "@shopify/react-native-skia";
import {useTheme, ThemeProvider} from "./docs/getting-started/Theme";

const MyDrawing = () => {
const { primary } = useTheme();
return <Fill color={primary} />;
};

export const Layer = () => {
const theme = useTheme();
return (
<Canvas style={{ flex: 1 }}>
{/* We need to re-inject the context provider here. */}
<ThemeProvider primary={theme.primary}>
<MyDrawing />
</ThemeProvider>
</Canvas>
);
};

export const App = () => {
return (
<ThemeProvider primary="red">
<Layer />
</ThemeProvider>
);
};
```

## Using `its-fine`

```tsx twoslash
Expand Down
4 changes: 3 additions & 1 deletion packages/skia/src/views/SkiaDomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ export class SkiaDomView extends React.Component<SkiaDomViewProps> {
assertSkiaViewApi();
SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize);
}
this.tick();
if (onSize !== prevProps.onSize || root !== prevProps.root) {
this.tick();
}
}

componentWillUnmount(): void {
Expand Down

0 comments on commit 0e4e74f

Please sign in to comment.