I'm new to using Electron so I'm probably missing something rather simple. I'm trying to implement some simple routing in my Electron app using react-router-dom but it doesn't seem like my program can find the right files. Looking at the dev tools, the structure looks like this: app structure. I have a React component that I'm trying to access as follows:
ReactDOM.render(
<HashRouter>
<Routes>
<Route path='/' element={<App />} />
<Route path='ConfigurationEditor' element={<ConfigurationEditor />} />
</Routes>
</HashRouter>,
document.getElementById('root'));
When I click on a button that changes the window location to "/ConfigurationEditor", I get an error like: Failed to load URL: file:///ConfigurationEditor with error: ERR_FILE_NOT_FOUND.
Looking back at the structure, this makes sense because the files for that component are buried in either the top/. or top/syntax-configuration-editor folders, not the file:// folder.
How do I get those folders under file:// (assuming that's the correct thing to do)?
Other potentially helpful/relevant info
- The window is created through
window.loadFile('index.html'). - In my
package.json, the"homepage"field is set to"./", and the"build"field looks as follows:
"asar": true,
"files": [
"**/*",
"dist/",
"node_modules/**/*",
"package.json",
"dist/main.js"
],
- The UI component:
<Button className={styles.buttonStyle}
variant='contained'
size='large'
color='primary'
fullWidth
onClick={(e) = {e.preventDefault;window.location.href="/ConfigurationEditor"}}
>
Configurations
</Button>