Automatically Update React Component Based on External Class Property Changes

I have an external JavaScript class (MyClass) with a property (number) that changes automatically, but I need to update a React component whenever this property changes. I cannot modify the external class (MyClass), only the react component.

Here’s a simplified example of what I’m trying to achieve:

class MyClass {
  constructor(name, number) {
    this.name = name;
    this.number = number;
    setInterval(() => this.incrementNumber(), 1000);
  }

  incrementNumber() {
    this.number += 1;
  }
}

And the React component:

import React, { useState, useEffect } from 'react';

function App() {
  const [obj, setObj] = useState(new MyClass("omri", 0));

  useEffect(() => {
    // How can I automatically update the component when obj.number changes?
  }, [obj]);

  return (
    <div>
      {obj.name} {obj.number}
    </div>
  );
}

Constraints:
Cannot modify the MyClass external class.
Need to update the React component automatically when the number property in the external class (MyClass) changes.

What are the alternative approaches or solutions to automatically update the React component when the number property in the external class changes without altering the class?

thank you!