how to run react native app


npm install -g react-native-cli

//cd to the file where your react native projects will be
react-native init albums

// Run instructions for IOS/Android
cd projects/albums

npx react-native run-ios
npx react-native run-android

react-native run-android
react-native run-ios

npm install -g react-native-cli

npx react-native init AwesomeProject

react-native start

$ npx react-native init firstapp

www.codegrepper.com
www.stackoverflow.com

how to run different node app on server different domains


var http = require('http'),
httpProxy = require('http-proxy');

var proxy_web = new httpProxy.createProxyServer({
target: {
host: 'localhost',
port: 8080
}
});

var proxy_api = new httpProxy.createProxyServer({
target: {
host: 'localhost',
port: 8081
}
});

http.createServer(function(req, res) {
if (req.headers.host === 'http://www.domain.com') {
proxy_web.proxyRequest(req, res);
proxy_web.on('error', function(err, req, res) {
if (err) console.log(err);
res.writeHead(500);
res.end('Oops, something went very wrong...');
});
} else if (req.headers.host === 'http://api.domain.com') {
proxy_api.proxyRequest(req, res);
proxy_api.on('error', function(err, req, res) {
if (err) console.log(err);
res.writeHead(500);
res.end('Oops, something went very wrong...');
});
}
}).listen(80);

www.codegrepper.com
www.stackoverflow.com

how to redirect react router from the app components


state = { redirect: null };

render() {
if (this.state.redirect) {
return <Redirect to={this.state.redirect} />
}
return(
// Your Code goes here
)
}

// update the redirect
this.setState({ redirect: "/someRoute" });

state = { redirect: null };
render() {
if (this.state.redirect) {
return <Redirect to={this.state.redirect} />
}
return(
// Your Code goes here
)
}

www.codegrepper.com
www.stackoverflow.com

how to reduce the size of my electron app


You can reduce the electron app size by packaging using electron-builder package.
PicArt is an electronjs app which I developed recently. It is built using reactJS.
Initially when I packaged the app using electron-packager the Window's build size was
around 98 MB.
Then I found this awesome boilerplate electron-react where they configured the
electron-builder to produced optimised build size.
After using those configuration setup, PicArt's build is now around 36 MB.

www.codegrepper.com
www.stackoverflow.com

how to put instagram post in react app


// Run the following command to install
// $ npm i react-instagram-embed

import InstagramEmbed from 'react-instagram-embed';

<InstagramEmbed
url='https://instagr.am/p/Zw9o4/'
maxWidth={320}
hideCaption={false}
containerTagName='div'
protocol=''
injectScript
onLoading={() => {}}
onSuccess={() => {}}
onAfterRender={() => {}}
onFailure={() => {}}
/>

www.codegrepper.com
www.stackoverflow.com