title: How to switch from remote to ipcMain and ipcRenderer?
body: <p>I am making electron app with react and I have titlebar controls done with remote module but in console I am getting warning that <code>remote</code> module is deprecated. I want to change my code to use <code>ipcMain</code> and <code>ipcRenderer</code> instead remote but I can't get it working.</p>
  <p>This is my code that is working 100% atm but with remote module. Can someone show on at least one function for example <code>app.minimize()</code> how to use <code>ipcMain</code> and <code>ipcRenderer</code>?</p>
  <pre><code>import { useState, useEffect } from &quot;react&quot;;
  import { remote } from &quot;electron&quot;;
  import {
    VscChromeMinimize,
    VscChromeMaximize,
    VscChromeRestore,
    VscChromeClose,
  } from &quot;react-icons/vsc&quot;;
  
  const TitlebarControls = ({ minimize, maximize, close }) =&gt; {
    const app = remote.getCurrentWindow();
    const [maximizeIcon, setMaximizeIcon] = useState(
      app.isMaximized() ? &lt;VscChromeRestore /&gt; : &lt;VscChromeMaximize /&gt;
    );
  
    useEffect(() =&gt; {
      app.on(&quot;maximize&quot;, () =&gt; setMaximizeIcon(&lt;VscChromeRestore /&gt;));
      app.on(&quot;unmaximize&quot;, () =&gt; setMaximizeIcon(&lt;VscChromeMaximize /&gt;));
    }, [app]);
  
    return (
      &lt;ul className=&quot;titlebar-controls&quot;&gt;
        {minimize &amp;&amp; (
          &lt;li className=&quot;minimize&quot; onClick={() =&gt; app.minimize()}&gt;
            &lt;VscChromeMinimize /&gt;
          &lt;/li&gt;
        )}
        {maximize &amp;&amp; (
          &lt;li
            className=&quot;maximize&quot;
            onClick={() =&gt;
              !app.isMaximized() ? app.maximize() : app.unmaximize()
            }
          &gt;
            {maximizeIcon}
          &lt;/li&gt;
        )}
        {close &amp;&amp; (
          &lt;li className=&quot;close&quot; onClick={() =&gt; app.close()}&gt;
            &lt;VscChromeClose /&gt;
          &lt;/li&gt;
        )}
      &lt;/ul&gt;
    );
  };
  
  export default TitlebarControls;
  </code></pre>