Skip to content
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

Error in NEXT.js "Failed to execute 'shaderSource' on 'WebGLRenderingContext'..." #42

Open
jonayWaka opened this issue Nov 30, 2022 · 1 comment

Comments

@jonayWaka
Copy link

jonayWaka commented Nov 30, 2022

I tried to install and run the demo in a Next.js project, and it prompt this error:

TypeError: Failed to execute 'shaderSource' on 'WebGLRenderingContext': parameter 1 is not of type 'WebGLShader'.

To Reproduce
Steps to reproduce the behavior:

  1. npm i shadertoy-react
  2. import ShadertoyReact from "shadertoy-react";
  3. Declare ```
    const fragmentShader = void main(void) { vec2 uv = gl_FragCoord.xy/iResolution.xy; vec3 col = 0.5 + 0.5*cos(iTime+uv.xyx+vec3(0,2,4)); gl_FragColor = vec4(col ,1.0); };
4. Include component inside render function `<ShadertoyReact fs={fragmentShader} />`.

**Expected behavior**
Same as demo.


**Desktop (please complete the following information):**
 - MacOs Monterey
 - Chrome
 - Versión 107.0.5304.110 (Build oficial) (x86_64)
@zdenham
Copy link

zdenham commented Apr 27, 2023

Hi @jonayWaka , I know this issue is a bit stale, but I ran into the same thing. If you are using create-next-app it will initialize it with reactStrictMode set to true.

In development this runs double renders to help identify non-deterministic side effects, but this causes issues with shadertoy-react

The solve is to set reactStrictMode to false in your next.config.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants