Just downloaded electron-react-boilerplate and started to play around with the boilerplate but problems raised when I tried to create a chomeless transparent windows, so I created a little React TitleBar component, but I don't know how can I send the widnow minimize, maximize and close commands. I know that some sort of work must be done with the ipcRenderer but I can't even import that into my React component
As for testing, downloaded electron-react-boilerplate 4.4.0 and tried to import ipcRenderer in the React App component, this is the resulting code of my React component, and I'm attaching the error that I get in the console.
import { Component } from 'react';
import { ipcRenderer } from 'electron';
import { MemoryRouter as Router, Switch, Route } from 'react-router-dom';
import icon from '../../assets/icon.svg';
import './App.css';
class Hello extends Component {
componentDidMount() {
console.log(ipcRenderer);
}
render() {
return (
<div>
<div className="Hello">
<img width="200px" alt="icon" src={icon} />
</div>
<h1>electron-react-boilerplate</h1>
<div className="Hello">
<a
href="https://electron-react-boilerplate.js.org/"
target="_blank"
rel="noreferrer"
>
<button type="button">
<span role="img" aria-label="books">
📚
</span>
Read our docs
</button>
</a>
<a
href="https://github.com/sponsors/electron-react-boilerplate"
target="_blank"
rel="noreferrer"
>
<button type="button">
<span role="img" aria-label="books">
🙏
</span>
Donate
</button>
</a>
</div>
</div>
);
};
}
export default function App() {
return (
<Router>
<Switch>
<Route path="/" component={Hello} />
</Switch>
</Router>
);
}
ERROR in ./node_modules/electron/index.js 1:11-24
Module not found: Error: Can't resolve 'fs' in '/home/martinb/Escritorio/electron-react-boilerplate-4.4.0/node_modules/electron'
@ ./src/renderer/App.tsx 10:19-38
@ ./src/renderer/index.tsx 10:30-46
ERROR in ./node_modules/electron/index.js 2:13-28
Module not found: Error: Can't resolve 'path' in '/home/martinb/Escritorio/electron-react-boilerplate-4.4.0/node_modules/electron'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
- install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "path": false }
@ ./src/renderer/App.tsx 10:19-38
@ ./src/renderer/index.tsx 10:30-46
webpack compiled with 2 errors
Not rewriting GET /index.html because the path includes a dot (.) character.