-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript error for Expo2DContext #30
Comments
I am having the same issue. Were you able to get this resolved? |
I've been researching this issue, looks like the var ctx = new Expo2DContext(gl.contextId, {
...
}) |
var ctx = new Expo2DContext(gl.contextId, {
...
}) This solution doesn't work in some cases when the context needs the functions in gl, it doesn't find them if you put a number... I propose an alternative that I am using for the moment, until this issue is solved import { ExpoWebGLRenderingContext, GLView } from "expo-gl";
import Expo2DContext, { Expo2dContextOptions } from "expo-2d-context";
interface YOUR_PROPS {}
const options: Expo2dContextOptions = {
fastFillTesselation: true,
maxGradStops: 128,
renderWithOffscreenBuffer: false
}
export const YOUR_COMPONENT: React.FC<YOUR_PROPS> = (props) => {
const onGLContextCreate = (gl: ExpoWebGLRenderingContext) => {
// @ts-ignore
var ctx = new Expo2DContext(gl, options);
// draw shapes
ctx.beginPath();
ctx.arc(40, 40, 40, 0, 2 * Math.PI);
ctx.stroke();
ctx.flush();
};
return (
<GLView style={{ width: 80, height: 80, backgroundColor: '#00000011' }} onContextCreate={onGLContextCreate} />
);
}; |
Something with the TypeScript code is off :/ |
Hi experts,
I was attempting to initialise the
Expo2DContext
according to the example inREADME.md
(here) and got some typescript errors on both parameters in the constructor. Currently, the type specified in the constructor is:constructor(gl: number, options: Expo2dContextOptions)
. Specifically:options
probably should be optional? This code suggests that we can just plug in anull
orundefined
and it should default correctly.gl
is probably notnumber
? From the example in theREADME.md
file, it should really be the input of theonContextCreate
props of theGLView
component? MaybeExpoWebGLRenderingContext
or at leastWebGL2RenderingContext
would be more appropriate thannumber
?Thanks for looking at my queries!!! 🙏 🙏
The text was updated successfully, but these errors were encountered: