@@ -38,25 +38,23 @@ function enhanceWithMessages(keyPrefix: string | undefined, WrappedComponent: Re
3838}
3939
4040/**
41- * An internal implementation of the argument resolution logic .
41+ * Creates a higher order component and provides the MessageSourceApi as `props` .
4242 *
43- * @param keyPrefixOrComponent the passed argument ([Component] | [[keyPrefix], [Component]])
44- */
45- function internalWithMessages ( keyPrefixOrComponent ?: string | React . ComponentType < any > ) {
46- if ( keyPrefixOrComponent == null || typeof keyPrefixOrComponent === 'string' ) {
47- // consumer used the curried API
48- return enhanceWithMessages . bind ( undefined , keyPrefixOrComponent ) ;
49- }
50-
51- return enhanceWithMessages ( undefined , keyPrefixOrComponent ) ;
52- }
53-
54- /**
5543 * Example usages:
5644 *
5745 * 1. MessageSource.withMessages('keyPrefix')(Component)
5846 * 2. MessageSource.withMessages(Component)
5947 * 3. compose(MessageSource.withMessages('keyPrefix'))(Component)
6048 * 4. compose(MessageSource.withMessages)(Component)
49+ *
50+ * @param keyPrefixOrComponent the passed argument ([Component] | [[keyPrefix], [Component]])
6151 */
62- export const withMessages = internalWithMessages ;
52+ export function withMessages ( keyPrefixOrComponent ?: string | React . ComponentType < any > ) {
53+ if ( keyPrefixOrComponent == null || typeof keyPrefixOrComponent === 'string' ) {
54+ return function wrapWithMessages ( Component : React . ComponentType < any > ) {
55+ return enhanceWithMessages ( keyPrefixOrComponent , Component ) ;
56+ } ;
57+ }
58+
59+ return enhanceWithMessages ( undefined , keyPrefixOrComponent ) ;
60+ }
0 commit comments