GLView check render method

Expo CLI version 4.1.6
web

I am new to Expo/reactive native, so sorry if this is a dumb question. I am trying to make an Expo CLI project using expo-2d-context, and the code is copied almost line for line from what I found at Introducing the Canvas 2D Context API for Expo | by Naomi Alterman | Exposition. I have installed GLView and Expo2DContext into my project and they are listed in package.json. However, when I try to run it for the web I get this error.

Here is my code:

import { GLView, Asset } from ‘expo’;
import React from ‘react’;
import Expo2DContext from ‘expo-2d-context’;
import { StyleSheet, Text, View } from ‘react-native’;

export default class App extends React.Component {

render() {
    return (
        <GLView style={{ flex: 1 }} onContextCreate={this._onGLContextCreate}/>
    );
}

_onGLContextCreate = (gl) => {
    var ctx = new Expo2DContext(gl);
    
    ctx.fillStyle = "grey";
    ctx.fillRect(20, 40, 100, 100);
    ctx.fillStyle = "white";
    ctx.fillRect(30, 100, 20, 30);
    ctx.fillRect(60, 100, 20, 30);
    ctx.fillRect(90, 100, 20, 30);
    ctx.beginPath();
    ctx.arc(50,70,18,0,2*Math.PI);
    ctx.arc(90,70,18,0,2*Math.PI);
    ctx.fill();

    ctx.fillStyle = "grey";
    ctx.beginPath();
    ctx.arc(50,70,8,0,2*Math.PI);
    ctx.arc(90,70,8,0,2*Math.PI);
    ctx.fill();

    ctx.strokeStyle = "black";
    ctx.beginPath();
    ctx.moveTo(70,40);
    ctx.lineTo(70,30);
    ctx.arc(70,20,10,0.5*Math.PI,2.5*Math.PI);
    ctx.stroke();

    ctx.flush();
}

}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.