Giter Site home page Giter Site logo

Comments (5)

ericf avatar ericf commented on May 2, 2024

@andrewholt was this in a particular browser, or all browsers that you noticed this?

Also, we've been working on creating a setup of React Components for v1.1.0 which we just did an RC1 release for. These include an HTML Message component to handle your use case here. https://github.com/yahoo/react-intl/releases/tag/v1.1.0-rc-1

from formatjs.

andrewholt avatar andrewholt commented on May 2, 2024

@ericf Indeed, this does work as expected in Safari (will display as $35.50). Although, in Safari, $10 will display as $10.00, and Chrome will show only $10, which seems more desirable.

We have already moved to using the HTML Message (thanks for that), but this issue still persists (presumably since it's an issue with the Intl object in Chrome, and the polyfill for Safari is working properly?).

from formatjs.

ericf avatar ericf commented on May 2, 2024

Yes this is an issue with Chrome. I'll check to make sure there's a bug open for their implementation of Intl.NumberFormat.

I checked Firefox and it formats 35.50 --> "$35.50" and 10 --> "$10.00" like the Intl.js polyfill does.

from formatjs.

andrewholt avatar andrewholt commented on May 2, 2024

Great, thanks so much. I'll close this out since it's not an issue with react-intl.

Thanks again!

from formatjs.

ericf avatar ericf commented on May 2, 2024

@andrewholt just a note on a workaround until Chrome fixes this, you can specify a value for minimumFractionDigits and set it to 0 if you want all env to render like Chrome, or 2 if you want to show cents. I would recommend using a named format for this so it's easier, e.g.:

var Component = React.createClass({
    mixins: [ReactIntl.Mixin],

    render: function () {
        return <ReactIntl.Number format="USD">{100}</ReactIntl.Number>;
    }
});

var intlData = {
    locales: 'en-US',
    formats: {
        number: {
            USD: {
                style: 'currency',
                currency: 'USD',
                minimumFractionDigits: 2
            }
        }
    }
};

React.render(
    <Component {...intlData} />,
    document.getElementById('example')
);

from formatjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.