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

react_1.useState is not a function in NextJS with Typescript #508

Open
rama142694 opened this issue May 20, 2023 · 4 comments
Open

react_1.useState is not a function in NextJS with Typescript #508

rama142694 opened this issue May 20, 2023 · 4 comments

Comments

@rama142694
Copy link

rama142694 commented May 20, 2023

hey! im using nextjs with typescript and im having this problem
image
i try to re make the project like in this another issue but it doesnt work.
Here is my code
image

and my folder structure
image

image

Originally posted by @rama142694 in #488 (comment)

@rama142694
Copy link
Author

trying several times i achieve to know a little bit more of where the problem is and it has something to do with the next js new app folder for routing. With the pages folder it works correct

@aditya-torinit
Copy link

aditya-torinit commented Jun 16, 2023

trying several times i achieve to know a little bit more of where the problem is and it has something to do with the next js new app folder for routing. With the pages folder it works correct

Do you have an example of how you implemented this in nextJs with
pages structure

I am getting following error for the same

TypeError: (0 , react_unity_webgl__WEBPACK_IMPORTED_MODULE_2__.useUnityContext) is not a function

This error happened while generating the page. Any console logs will be displayed in the terminal window.

@rama142694
Copy link
Author

trying several times i achieve to know a little bit more of where the problem is and it has something to do with the next js new app folder for routing. With the pages folder it works correct

Do you have an example of how you implemented this in nextJs with pages structure

I am getting following error for the same

TypeError: (0 , react_unity_webgl__WEBPACK_IMPORTED_MODULE_2__.useUnityContext) is not a function

This error happened while generating the page. Any console logs will be displayed in the terminal window.

Yes, here is the folder structure:
image

and here is the implementation on the index page:
image

@tylermcdonald
Copy link

Hey, I got this same issue. I believe it has to do with "By default, components inside app are React Server Components." which is a new part of NextJS 13. I was able to fix it by converting the component which included my Unity component to a client component by adding the 'use client' directive at the top of the file. https://nextjs.org/docs/getting-started/react-essentials#client-components

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

3 participants