transformContext.js 413 Bytes
Newer Older
Sangjune Bae's avatar
Sangjune Bae committed
1
2
3
4
5
6
7
8
9
10
11
12
13
import React from 'react';
import forwardRef from './forwardRef';
export default function transformContext(Context) {
  return forwardRef(function (props) {
    return React.createElement(Context.Consumer, null, function (context) {
      return React.createElement(Context.Provider, {
        value: props.mapToValue(context)
      }, props.children);
    });
  }, {
    displayName: 'ContextTransformer'
  });
}