Go Pro Sign Up Login
0 days 0 hrs 0 min 0 sec

Summer Sale

50% off Level Up Pro until you unsubscribe.
Get access to ALL 128 courses on Level Up Tutorials

This is your last chance to get Level Up Pro for $145/year.

or Learn More
Moon Moon

Buy Now and unlock this series

$

49

.99

$

24

.99

yours forever

Become a Pro and unlock everything

$

24

.99

per month

Controlling useEffect

Downloads

Become a pro to download code and videos

Comments

User avatar

Raul

almost 2 years ago [edited]

@question Yes, useMemo will work for the provided example. However, it could be argued if it's a correct use semantically speaking.

question

almost 2 years ago

could u use a useMemo?

User avatar

Raul

about 2 years ago [edited]

@Cris Maybe the site was blocking temporarily. I've just tested it and it seems to work fine. Let us know if it's still happening

User avatar

Steven

over 2 years ago

This is incredible, I've loved this series so much.

Cris

almost 3 years ago

I am having issues calling the api.

Access to fetch at 'https://my-json-server.typicode.com/leveluptuts/fakeapi/dishes' from origin 'http://localhost:3000' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'https://localhost:3000' that is not equal to the supplied origin. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I try to set the mode to no-cors but doesnt seem to be working

Amber

about 3 years ago

Technically, shouldn't "fetchDishes" be passed in the dependency array? This does cause a constant call since it is redefined for each render. But I feel like omitting it is a bad practice since there is no guarantee that "fetchDishes" value will never change.

Want to join the conversation?

Become a Pro member today!