Help with NativeTheme Emitter

Hello all!

I’m new to this discourse, but I’m interested in trying to get auto dark mode working on Mailspring.

I’m trying to use electron’s NativeTheme to automatically detect when the system theme changes.

import { React } from "mailspring-exports";
const ThemeManager = AppEnv.themes;
const electron = require("electron");
const nativeTheme = electron.remote.nativeTheme;

export default class AutoTheme extends React.Component {
  static displayName = "AutoTheme";
  constructor(props) {
    super(props);
  }

  doSomething() {
    console.log("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
  }

  componentDidMount() {
    console.log(ThemeManager.getBaseTheme());

    console.log(nativeTheme.shouldUseDarkColors);
    nativeTheme.on("updated", () => {
      this.doSomething();
    });
  }

  render() {
    return null;
  }
}

I’ve confirmed that the NativeTheme “updated” emitter works in another node project, however, it never triggers in this context. I’m very new to javascript, let alone react and electron, so I’m hoping someone can help me!

Thank you!