Install ReactJs on Codeanywhere

The way I did:

  • Log in to https://codeanywhere.com
  • Create a blank container by clicking File > New Connection > Container
  • Choose “Blank Development Stack” Ubuntu OS
  • It will open two tabs
  • Copy Container related information somewhere.  This information will have web address. This is the address you’ll need to view your application.
  • Go to terminal (this should be first opened tab)
sudo apt-get update
sudo apt install curl
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash - 
sudo apt-get install nodejs
sudo apt-get install npm 
sudo npm install -g create-react-app 
create-react-app my-react-app 
cd my-react-app 
npm start

You’ll see http://localhost:3000 in your terminal. Ignore that. Use the web address you have copied before.

Happy coding!

jQuery: Using window url parameter

Let’s say we have passed a parameter to URL: www.mysite.com/?page=test

To collect the data form parameter we can use this function:

function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};

use of this code:

getUrlParameter('page');

or

if (getUrlParameter('page') == 'test'){
// do something
}