Skip to content

Clarification: Wrapping Intl.NumberFormatter format function in an atom/atomFamily #2954

Answered by dmaskasky
peterpme asked this question in Q&A
Discussion options

You must be logged in to vote

@dmaskasky although I can see what stableStringify and numberFormatter are doing, I couldn't exactly figure out how to use that in a react component since numberFormatter looks like a function and using _numberFormatter directly did not utilize those functions. Am I missing something?

Happy to explain my code. Here's a simple codesandbox to start 😊.

I realize I should have taken more time to prepare my answer. There were several mistakes in my original solution. I've corrected them now.

createMemoizedNumberFormatterFamily doesn't accept any arguments. It sets up initial conditions (map + atomFamily), to be used later. This is the key component of memoizing the Intl.NumberFormatOptions. …

Replies: 4 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@dmaskasky
Comment options

@peterpme
Comment options

Comment options

You must be logged in to vote
4 replies
@peterpme
Comment options

@peterpme
Comment options

@dmaskasky
Comment options

@peterpme
Comment options

Answer selected by peterpme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants