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

JS Error in v1.3.13 #185

Closed
circlecube opened this issue Dec 4, 2023 · 1 comment
Closed

JS Error in v1.3.13 #185

circlecube opened this issue Dec 4, 2023 · 1 comment

Comments

@circlecube
Copy link
Member

Seeing a JS error which breaks the React app. It states

Warning: useEffect must not return anything besides a function, which is used for clean-up.

It looks like you wrote useEffect(async () => ...) or returned a Promise. Instead, write the async function inside your effect and call it immediately:

useEffect(() => {
  async function fetchData() {
    // You can await here
    const response = await MyAPI.getData(someId);
    // ...
  }
  fetchData();
}, [someId]); // Or [] if effect doesn't need props or state

I believe I've pinpointed it to this line which was included in v1.3.13:

useEffect(async () => {
    const data = await useThumbnail(NewfoldRuntime.homeUrl);
    setThumbnail(data?.thumbnail_loc);
}, []);

See: https://github.com/newfold-labs/wp-module-ecommerce/blob/trunk/src/components/OnboardingScreen.js#L52-L55 & v1.3.12...v1.3.13#diff-fd672c79443c2dc41c55d1d45484f87c38f677499a7a938d75860dc61b947270R52-R55

circlecube added a commit that referenced this issue Dec 4, 2023
circlecube added a commit that referenced this issue Dec 4, 2023
@circlecube
Copy link
Member Author

Fixed in v1.3.14

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

1 participant