how do I take a number like 10000
and have it output as $10,000.00
?
I even had a problem with String.format(...)
with a
The fastest way is to use react-number-format, as stated above, but don't forget the renderText
prop so that React Native don't throw rendering error.
Follow this step:
npm i react-number-format
import NumberFormat from 'react-number-format';
export function ReactNativeNumberFormat({ value }) {
return (
{formattedValue} } // <--- Don't forget this!
/>
);
}
It's working good. As you can see, I ended up creating my custom component that accept value
as prop so I can use it everywhere I need it. Just like this:
Hope can be useful.
PS: This is my reference => https://github.com/s-yadav/react-number-format/issues/17#issuecomment-395187806.