Notes about React here, primarily for Good Music Classifier project.
What is Node.js?
$ sudo apt-get install nodejs
Great! Now you can just run
Time to create our app!
$ npm install -g create-react-app
This installs the package create-react-app. Now, we can use this package. Go to your new app’s director and:
$ create-react-app APPNAME
This package creates a skeleton app for us. Thanks! And there’s your app!
$ cd APPNAME $ npm start
What’s going on?
There’s a bunch of folders in this APPNAME folder.
- node_modules: Contains all the packages and modules needed for this app. See link
- public: Contains the code that is publically known (HTML). More documentation here
- src: Our actual app.
- package.json: A list of the dependencies that the package has (The npm modules that we’re using). When adding more dependencies, they’ll go here.
And if you haven’t already, editing App.js will live-update your app on the web browser.
What’s nice about React?
React is essentially a bunch of independent components that are composed together to build an interactive user interface. It handles DOM Elements as ‘Virtual DOMs,’ which handles state changes and then updates the real DOM elements on our web page. We no longer have to work with the DOM API (event handlers, query …). React will automatically handle all of that when it receives a state change.