How to clone or monkey patch a React Component so one method changes

Let’s say we have

class OriginalComponent extends Component {
  // various code..
  someFunction = () => {
    // does stuff
  }
}

I want to get the functionality of OriginalComponent but with the change that someFunction is replaced with different functionality.

I can think of two possible ways to do this:

  1. Define NewComponent through inheritance:
class NewComponent extends OriginalComponent {
  // various code..
  someFunction = () => {
    // does new stuff
  }
}
  1. Directly change the prototype on OriginalComponent:
OriginalComponent.prototype.methodName = function() 
{ 
  // does new stuff
}

Do both of these methods work? Do they differ? What is recommended here.

I am using a third party library that allows me to pass in overrides for particular React components in the config, for context.