title: React-intl for non components
body: <p>Currently I have the following code to expose react-intl to non-components, but it throws an error for intl as undefined.</p>
  
  <p>I have created a separate component as 'CurrentLocale' and inject-intl to it. The exporting function t will use intl formatMessage from CurrentLocale context.</p>
  
  <pre><code>import React from 'react';
  import {injectIntl} from 'react-intl';
  import PropTypes from 'prop-types';
  import { flow } from 'lodash';
  
  class CurrentLocale extends React.Component {
  
  
      constructor(props,context){
  
          super();
          console.log(context,props);
          console.log(this.formatMessage);
          const { intl } = this.context.intl;//this.props;
  
          this.formatMessage = intl.formatMessage;
      }
  
      render() {
          return false;
      }
  }
  CurrentLocale.contextTypes={
      intl:PropTypes.object,
  };
  
  
  injectIntl(CurrentLocale);
  
  function intl() {
      return new CurrentLocale();
  }
  
  function formatMessage(...args) {
      return intl().formatMessage(...args);
  }
  
  
  const t = opts =&gt; {
      const id = opts.id;
      const type = opts.type;
      const values = opts.values;
      let t;
  
      switch (type){
  
          case 'message':
          default:
              t = formatMessage(id, values);
      }
  
      return t;
  }
  
  export default t;
  </code></pre>
  
  <p>t is called as in another plain javascript file as, </p>
  
  <pre><code>import t from './locale/t';
  t( { type: 'message', id:'button.Next'});
  </code></pre>
  
  <p>Following is the error message.
  <a href="https://i.stack.imgur.com/9AeXt.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9AeXt.png" alt="enter image description here"></a>
  Thanks in advance.</p>