Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number/Date/Mixin components exposed as IntlNumber/IntlDate/IntlMixin #60

Closed
pselden opened this issue Jan 14, 2015 · 3 comments · Fixed by #67
Closed

Number/Date/Mixin components exposed as IntlNumber/IntlDate/IntlMixin #60

pselden opened this issue Jan 14, 2015 · 3 comments · Fixed by #67

Comments

@pselden
Copy link

pselden commented Jan 14, 2015

This is a feature request to export the Number/Date/Mixin components as IntlNumber/IntlDate/Mixin.

I love using the ES6 object destructuring syntax, but when I'm consuming react-intl components I cannot use it because it would "hide" the built in Number/Date types. Mixin is slightly different in that there is no conflict -- I just always rename it to IntlMixin to make it a bit more clear about it's use.

I'd love to be able to do the following.

var { IntlNumber, IntlDate, IntlMixin } = require('react-intl');

Instead of

var ReactIntl = require('react-intl'),
  IntlNumber = ReactIntl.Number,
  IntlDate = ReactIntl.Date,
  IntlMixin = ReactIntl.Mixin;

And if you end up going this route, I'd probably prefix the other ones with Intl for consistency.

@ericf
Copy link
Collaborator

ericf commented Jan 14, 2015

Yeah, I've run into this too and agree it's not good. In terms of ES5 compatible syntax, ReactIntl.Number looks better than ReactIntl.IntlNumber, but I'm on board with focusing on the future and assuming ES6 modules will prevail in the long term. The problem is ES6 modules also support the "namespacing" approach of ReactIntl.*.

Currently you can do this, but dot-notation in the JSX looks odd:

var ReactIntl = require('react-intl');

<ReactIntl.Number>{1000}</ReactIntlNumber>

As for ES6 module instance you can also do:

import {Number as IntlNumber} from 'react-intl';

or…

import * as ReactIntl from 'react-intl';

@ericf
Copy link
Collaborator

ericf commented Jan 14, 2015

@caridy any thoughts on this?

@caridy
Copy link
Collaborator

caridy commented Jan 15, 2015

🍹

ericf added a commit to ericf/react-intl that referenced this issue Jan 16, 2015
@ericf ericf changed the title [1.1.0-pre] Number/Date/Mixin components exposed as IntlNumber/IntlDate/IntlMixin Number/Date/Mixin components exposed as IntlNumber/IntlDate/IntlMixin Jan 16, 2015
ericf added a commit to ericf/react-intl that referenced this issue Jan 21, 2015
This adds "Formatted" as a prefix to all React Intl Components.
See: formatjs#65 for discussion

Closes formatjs#64
Fixes formatjs#60
@ericf ericf closed this as completed in #67 Jan 21, 2015
longlho pushed a commit that referenced this issue Apr 27, 2020
Refactor: using ES6 and transpiring to global and CommonJS
longlho pushed a commit that referenced this issue Apr 27, 2020
Safari now supports Intl since v10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants