Could the useState be used without the setter? episode artwork

EPISODE · Dec 13, 2021 · 6 MIN

Could the useState be used without the setter?

from The Call Kent Podcast · host Kent C. Dodds

I have a question... could the useState be used without using the setter? because a teammate use it in that way to get an item from sessionStorageconst [initialScrollPosition] = useState(() => Number.parseFloat(sessionStorage.getItem('offset') || 0)); and argues that this is so that the component is not unnecessarily rerendered and to read the sessionStorage only once! 🤔 but I think we can use useMemo for those cases but the useState is still used in this form in several components.useState lazy initialization and function updates

Episode metadata supplied by the publisher feed · Published Dec 13, 2021

Embed this episode

NOW PLAYING

Could the useState be used without the setter?

0:00 6:03

No transcript for this episode yet

We transcribe on demand. Request one and we'll notify you when it's ready — usually under 10 minutes.

No similar episodes found.

No similar podcasts found.

Frequently Asked Questions

How long is this episode of The Call Kent Podcast?

This episode is 6 minutes long.

When was this The Call Kent Podcast episode published?

This episode was published on December 13, 2021.

Can I download this The Call Kent Podcast episode?

Yes. Use the download control on the episode player to save the publisher-provided media file.
URL copied to clipboard!