Open yukosgiti opened 2 years ago
A little more context: It happens on React 18 only. Just tested it with a fresh project with React 17 and it's working.
It is also failing on everything shader related thing that I tried. Even making a shader program from scratch throws the same error so it's probably not related to the library per se but if @gre or someone with more WebGL experience can check it out it'd be better.
Mmh curiously the cookbook uses React 18. I will have to recreate a basic example to try to reproduce. But I'm using React + GL React ~ every week, making art projects of my own with it and never experienced this 👀
Was able to pinpoint this issue to this file in gl-shader
: https://github.com/stackgl/gl-shader/blob/master/lib/shader-cache.js (line 55). Guess it's out of the scope of the library though
I think this is related to React 18 Strict Mode.
If you create a fresh project with create-react-app and add gl-react and gl-react-dom you can reproduce the issue.
If you comment the out strict mode in src/index.js
the error goes away:
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
- <React.StrictMode>
<App />
- </React.StrictMode>
);
Library Version
I use React 18.
Expected Behavior
This code to render.
Actual behavior
I get the following error:
From my limited debugging, in the
compileShader
The
shader
variable isnull
. Whic gives the error I think.type
is35633
andsrc
isSteps to reproduce the behavior
I tried to implement the first example in the docs. I get this error in Opera, Firefox and Chrome.