Last active
November 9, 2015 18:19
-
-
Save ericf/c7296c5bd064df02c16e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2015, Yahoo Inc. | |
* Copyrights licensed under the New BSD License. | |
* See the accompanying LICENSE file for terms. | |
*/ | |
import {Component, Children, PropTypes} from 'react'; | |
import {intlShape} from '../types'; | |
import {invariantIntlContext} from '../utils'; | |
export default class MessagesProvider extends Component { | |
constructor(props, context) { | |
super(props, context); | |
invariantIntlContext(context); | |
} | |
getChildContext() { | |
return { | |
intl: { | |
...this.context.intl, | |
messages: this.props.messages, | |
}, | |
}; | |
} | |
render() { | |
return Children.only(this.props.children); | |
} | |
} | |
MessagesProvider.displayName = 'MessagesProvider'; | |
MessagesProvider.contextTypes = { | |
intl: intlShape, | |
}; | |
MessagesProvider.propTypes = { | |
messages: PropTypes.object, | |
}; | |
MessagesProvider.defaultProps = { | |
messages: {}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment