File tree Expand file tree Collapse file tree 4 files changed +21
-4
lines changed Expand file tree Collapse file tree 4 files changed +21
-4
lines changed Original file line number Diff line number Diff line change 9
9
10
10
< title > Example</ title >
11
11
<!-- The `react-native-web` recommended style reset: https://necolas.github.io/react-native-web/docs/setup/#root-element -->
12
- < style id ="expo -reset ">
12
+ < style id ="react-native-web -reset ">
13
13
/* These styles make the body full-height */
14
14
html ,
15
15
body {
Original file line number Diff line number Diff line change @@ -69,9 +69,19 @@ export const Canvas = forwardRef<
69
69
const cb = useRef < ( ) => void > ( ) ;
70
70
const { size, onLayout } = useSize ( viewRef ) ;
71
71
useEffect ( ( ) => {
72
- if ( size && cb . current ) {
72
+ const hasNonZeroDims = ! ! size ?. height && ! ! size ?. width ;
73
+ if ( size && hasNonZeroDims && cb . current ) {
73
74
cb . current ( ) ;
74
75
}
76
+
77
+ if ( size && ! hasNonZeroDims ) {
78
+ console . warn (
79
+ [
80
+ `react-native-wgpu canvas has zero dimensions (width:${ size . width } px; height:${ size . height } px)!` ,
81
+ "Unable to initialize underlying canvas." ,
82
+ ] . join ( " " ) ,
83
+ ) ;
84
+ }
75
85
} , [ size ] ) ;
76
86
77
87
useImperativeHandle ( ref , ( ) => ( {
Original file line number Diff line number Diff line change
1
+ import "@webgpu/types" ;
2
+
1
3
export * from "./main" ;
4
+
5
+ declare global {
6
+ interface Navigator {
7
+ gpu : GPU ;
8
+ }
9
+ }
Original file line number Diff line number Diff line change @@ -201,8 +201,7 @@ if (!navigator) {
201
201
// @ts -expect-error
202
202
navigator = { } ;
203
203
}
204
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
205
- // @ts -expect-error
204
+
206
205
navigator . gpu = RNWebGPU . gpu ;
207
206
208
207
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
You can’t perform that action at this time.
0 commit comments