Skip to content

Commit 8697e03

Browse files
committed
Add usePaperScope, export PaperScopeSettings type
1 parent be2a4fa commit 8697e03

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-paper-bindings",
3-
"version": "3.0.0-beta.12",
3+
"version": "3.0.0-beta.13",
44
"description": "Paper.js renderer for React",
55
"author": "Bojan Hribernik <bojan.hribernik@gmail.com>",
66
"license": "MIT",

src/Canvas.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export type PaperScopeSettings = {
1717
hitTolerance?: number;
1818
};
1919

20-
export type Props = React.ComponentProps<'canvas'> & {
20+
export type CanvasProps = React.ComponentProps<'canvas'> & {
2121
width: number;
2222
height: number;
2323
settings?: PaperScopeSettings;
@@ -29,7 +29,7 @@ export type CanvasRef = HTMLCanvasElement | null;
2929
export type ScopeRef = paper.PaperScope | null | undefined;
3030
export type FiberRef = FiberRoot | null;
3131

32-
export const Canvas = forwardRef<CanvasRef, Props>(function Canvas(
32+
export const Canvas = forwardRef<CanvasRef, CanvasProps>(function Canvas(
3333
{ children, width, height, settings, scope, onScopeReady, ...props },
3434
forwardedRef
3535
) {

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export { Renderer } from './Renderer';
22
export { Canvas } from './Canvas';
3-
export type { Props as CanvasProps } from './Canvas';
4-
export { PaperScope } from 'paper/dist/paper-core';
53
export * from './Items';
4+
export { usePaperScope } from './usePaperScope';
5+
export { PaperScope } from 'paper/dist/paper-core';
6+
export type { CanvasProps, PaperScopeSettings } from './Canvas';

src/usePaperScope.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { useRef } from 'react';
2+
import { PaperScope } from 'paper/dist/paper-core';
3+
4+
export const usePaperScope = () => {
5+
const scopeRef = useRef(new PaperScope());
6+
return scopeRef.current;
7+
};

0 commit comments

Comments
 (0)