score:0
Wow. That certainly seems interesting.
You can build the react app and then wrap Electron around it instead of running a react server. yarn build
should do the trick if you are using create-react-app boilerplate.
You need to make sure the build path is correct. This is the reason why your built react app is empty in the Electron.
So, that all the variables are correctly being called from index.html
. You can achieve this functionality by specifying "homepage":"./"
in package.json
. You will have to find out what path Electron for absolute reference. Or perhaps you can open a static
endpoint for all files in build directory. You will have to figure that out. I have never worked with Electron.
Check this. Here it says "homepage":"./" should work.
https://medium.com/@brockhoff/using-electron-with-react-the-basics-e93f9761f86f
As for node server I am sure you must be making calls to the API endpoints you have written. If not you can do so using native Javascript. I personally prefer using axios.
import axios from 'axios';
async componentWillMount(){
const result = await axios.get(localhost:8080/get)
console.log(result)
// You can now directly display result on the react app or save it save.
this.setState({result:result})
}
Axios Package: https://www.npmjs.com/package/axios
score:2
I figured out the solution. When wrapping electron using react, the react app has to use a hashRouter instead of browserRouter. For details checkout my other question: How to use React HashRouter for route query parameters?
Then to wrap the node server, put the node server folder as a dependency in React app folder's package.json. then run npm install to install it as an dependency. Then require the main starting file for node server in electron's starting file this starts the server.
Source: stackoverflow.com
Related Query
- how to build a standalone desktop app built with react, using a node backend, and wrap both frontend and backend in electron as a desktop app?
- I create a build of my react app and connected with electron.js. now how to connect my backend from server folder with electron
- How to build react app using Dockerfile.dev and Yarn
- How to run a React Native App with Node js Backend on Android Device?
- how to run my node application and react app in the same time with one command?
- How can I build a React app with Webpack and import an assets folder?
- How to determine the order of css in my create react app build with webpack and customize-cra?
- How to deploy React app with docker and serve -s build
- How to authenticate user from standalone react frontend with django backend (same domain, different ports), using a third-party CAS authentication?
- How to send data and photo at same time to node js backend using axios in react js
- how to fix CORS problem in node and react app with socket.io
- I am using socketio with react as the frontend and node with express js to make an app
- How to persist user login in a React & Redux, express backend app with JWT and without packages like redux-persist?
- How can I update react app that gets it's data from the node mongo backend using redux
- How to deploy an already built react app with express.js backend to heroku
- How do I store JWT and send them with every request using react
- How to show build datetime on my react web app using create-react-app?
- Why does production build of React app (with Webpack and Babel) use wrong development env with HMR, which causes errors?
- Error using component done with react,redux and react-redux and build with webpack in react application
- How to inject port and host using ENV variable in Create React App Proxy settings?
- How to distribute fonts or other static assets with a React component library built using Webpack?
- Using Jquery and Bootstrap with Es6 Import for React App
- How to analyze create react app build size and reduce it?
- How to read console.log from a mounted component with Enzyme and Jest in Create React App
- How to reduce react app build time and understanding behaviour of webpack when bundling
- How can I start my node server and react app at the same time?
- how to change image src using props with styled component and react
- How to serve React app with Material-UI and react-router
- How to make Node and React app to share classes
- Staticfile deployment of built React app to Cloud Foundry seems to think it is a Node deployment, even with buildpack
More Query from same tag
- How to delete data from table in reactjs?
- window not defined error when using extract-text-webpack-plugin React
- ReactJS & django-forms
- Unable to find solution - showing error in this way - "Attempted import error: 'date-fns' does not contain a default export (imported as 'dateFns')."
- Table in Reactjs Data Structures
- Jest Testing an asynchronous image upload in React
- [SPLoaderError.loadComponentError]: ***Failed to load component
- React filtering array of object by input text and category selection by button click
- How to use the <style> balise in React file
- How to save CSV file from API response using React?
- How to integrate timepicker in material-table
- Fetching two type of data from same API
- Material Table Add Row position
- UseCallback in combination with StrictMode
- How to achieve an async function chain with await when the functions are parent and child?
- Mui-Datatable onTableChange is not working when adding a setState
- Simple react functional component not generating HTML
- Get properties from Routes
- react-router-dom nested routes and redirects
- Fetch just once with Redux then load from store
- React running a function inside onClick of a button inside parent component
- How to handle React nested component circular dependency? (using es6 classes)
- Value below was evaluated just now in console.log after trying to log this.state updated values
- How to assign variables in .env file?
- Instantly updating UI with state
- Unexpected keyword 'this' in React class component
- Style cell in react-datasheet-grid
- How to Add Default Elements to an Array when Requirements Not Met?
- How to display one value from many inputs randomly with React hooks
- Is there a better way to check if a variable exists in Javascript?