Change the way of injecting Intl

Bug #1657388 reported by Jiri Tomasek
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tripleo
Expired
Undecided
Unassigned

Bug Description

It may be worth investigating if it would be possible to pass intl prop without having to wrap every component with injectIntl(Component). IIUC this is used to make intl prop available for the component.

Maybe we could wrap just injectIntl(App) and make App provide intl in context:

class App extends React.Component {
  getChildContext() {
    return {intl: this.props.intl};
  }
  ...
}
App.childContextTypes = {
  intl: React.PropTypes.object
};

Any component would then grab intl from context as 'this.context.intl'

class AnyComponent extends React.Component {
...
this.context.intl.formatMessage
...
}
AnyComponent.contextTypes = {
  intl: React.PropTypes.object
};

See https://facebook.github.io/react/docs/context.html for more info on how context works

Tags: ui
Revision history for this message
Jason E. Rist (jason-rist) wrote :

I'm nervous about doing this. At least with injectIntl, it's extremely clear what's happening.

Changed in tripleo:
milestone: pike-1 → pike-2
Changed in tripleo:
milestone: pike-2 → pike-3
Changed in tripleo:
milestone: pike-3 → pike-rc1
Changed in tripleo:
milestone: pike-rc1 → queens-1
Changed in tripleo:
milestone: queens-1 → queens-2
Changed in tripleo:
milestone: queens-2 → queens-3
Changed in tripleo:
milestone: queens-3 → queens-rc1
Changed in tripleo:
milestone: queens-rc1 → rocky-1
Changed in tripleo:
milestone: rocky-1 → rocky-2
Changed in tripleo:
milestone: rocky-2 → rocky-3
Changed in tripleo:
milestone: rocky-3 → rocky-rc1
Changed in tripleo:
milestone: rocky-rc1 → stein-1
Changed in tripleo:
milestone: stein-1 → stein-2
Revision history for this message
Emilien Macchi (emilienm) wrote : Cleanup EOL bug report

This is an automated cleanup. This bug report has been closed because it
is older than 18 months and there is no open code change to fix this.
After this time it is unlikely that the circumstances which lead to
the observed issue can be reproduced.

If you can reproduce the bug, please:
* reopen the bug report (set to status "New")
* AND add the detailed steps to reproduce the issue (if applicable)
* AND leave a comment "CONFIRMED FOR: <RELEASE_NAME>"
  Only still supported release names are valid (FUTURE, PIKE, QUEENS, ROCKY, STEIN).
  Valid example: CONFIRMED FOR: FUTURE

Changed in tripleo:
importance: Medium → Undecided
status: Triaged → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.