function getChildContext (componentPrototype, instance, context) {
  if (componentPrototype.childContextTypes) {
    return Object.assign(Object.create(null), context, instance.getChildContext());
  }
  return context;
}
Code originally borrowed from the Rapscallion project:
https://github.com/FormidableLabs/rapscallion/blob/44014d86a0855f7c3e438e6a9ee1e2ca07ff2cbe/src/render/context.js