-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Document why <Formatted*> components are better than the imperative API #117
Comments
This is a good idea and I can add docs about this. That said, there will be an imperative API because it's still needed for certain types of formatting; e.g., an element's prop value, like A major area where the components provide value is in composition of complex messages See: https://github.com/yahoo/react-intl/blob/master/src/components/message.js And as we gain more guidance from React on |
Yes I'm trying to pass in placeholder values, I'm using 2.0.0-beta-2, I've looked a the code and can't see a way to do this? |
|
hmmm. shame I can't get this to be apart of all props in some way without having to decorate many components. thanks for your help @slorber |
@export-mike be part of all props is like using react context, and decorator only extracts from the context. What is your problem with the following I don't understand? var React = require("react");
var ReactIntl = require("react-intl");
var SearchBar = React.createClass({
...
render() {
var placeholder = this.props.intl.formatMessage({ id: "searchBar.searchPlaceholder" });
var inputValue = this.input();
return (
<input
value={inputValue}
onChange={this.onInputChange}
forceVisibility={this.isValid(inputValue)}
placeholder={placeholder}
/>
);
}
});
module.exports = ReactIntl.injectIntl(SearchBar); |
@export-mike are you talking about <FormattedMessage
id="greeting"
defaultMessage="Hello, {name}!"
values={{
name: 'Eric'
}}
/> |
It's to populate a property that expects a string such as placeholder. I'm On Fri, 12 Feb 2016 19:50 Eric Ferraiuolo [email protected] wrote:
|
@export-mike Here are some docs on the injection API: https://github.com/yahoo/react-intl/wiki/API#injection-api |
Put some details on "Why Component?" on the Wiki: |
@ericf thanks for your help. |
Hi,
Just wanted you to be aware that we had in Paris a ReactJS Meetup about I18n and I asked a question nobody could answer: what's the advantage of using React components for formatting instead of using directly the - maybe deprecated - mixin API
this.format()
.I think it should be clearly documented what are the advantages of a component over an imperative API
The only thing I guess so far is maybe the possibility to inject React components as template parameters, and maybe cacheability but I'm not sure at all :)
The text was updated successfully, but these errors were encountered: