React is a user interface library that was developed at Facebook. React is written in different components and follows the principles of immutable data. It’s often used in enterprise applications, and it makes creating single page applications easier since they have a higher speed thanks to the virtual DOM. This means it writes to the browser DOM only when it is needed, instead of re-rendering an entire view when a change is made.
React creates an in-memory DOM where it only renders different parts of the DOM when a change occurs.
React applications consist of a collection of components. Components are small user interface elements that display data as it changes over time. Used together, these components create entire user interfaces.
Component lifecycles allow you to add libraries and load data at specific times. They also help improve the speed of an application, with lifecycle methods that you can override to run code a specific times in the process.
Mounting methods are called when an instance of a component is being created:
Updating methods occur when a change happens to props or state:
Unmounting methods are called when a component is being removed:
Earlier today, I worked on putting together this Sticky Note App, in an effort to get more comfortable with React.js. The application uses React.js, React DOM, and React Draggable.
After completing my application, I was about to tackle deployment with Heroku, since I’ve become pretty familiar with deploying various applications that consist of different stacks on Heroku.
However, this application was a lot simpler, so it seemed like using Heroku would have been a little excessive, especially since there’s no backend component for this application.
So I decided to tackle deploying the application via GitHub pages – which is already one of my favorite ways to deploy simple applications since I host all my repos there as well.
The first step I did, was use the
create-react-app command in my terminal, where I then moved the various components of my simple React application. Then I followed the following steps:
Edit package.json by adding a homepage
"homepage": "https://[insert username].github.io/[insert project repo name]"
npm install --save-dev gh-pages
Edit package.json by adding a predeploy and deploy script:
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
npm run deploy
And there you have it, a simple enough solution for deploying those simple enough React applications.
Over the weekend I spent a good chunk of time working on my project. And then again all day today and tonight I alway hacked away at it. Unfortunately, I had to come to the conclusion that I need to start the whole project over tomorrow. Why, you may ask?
Well, I didn’t realize that working with HTML5 canvas and React would prove to be a bit complicated. I also realized that I don’t understand React as thoroughly as I’d like to in order to create a complete and polished product.
When it came down to it, it was more important to me that I build something new to add to my portfolio that I can be proud of. After project week, I can always explore React and the MEAN stack once more. And at that point in time, I can also take my time with my work without the pressure of a project deadline.
Today was our project 4 kickoff. The day started off with the instructors walking through project expectations and the submission process, as well as a general overview of what the project week will look like.
I’ve also decided to attempt to build the app in React with Express and Mongo DB. I’m not at all familiar with the deployment process for this particular stack, so we shall see how that goes. If I run into too many issues in the beginning, I might just build everything out with technologies I’m more familiar with so that I can have a polished app. I can always explore these more difficult frameworks later on with a different and simpler application.
Today was more of an open-ended day. We had the option to work on a React JS lab or spend the day researching a technology of our choosing. I decided to do some serious document diving with React. Front-end frameworks are tough, especially for someone who is being exposed to them for the first time. So I did my best not to get frustrated when I wasn’t learning as quickly as I’d like to.
One thing that was pretty helpful was walking through the React Router tutorial. It gave me a better sense of how all the files are tied together in React, however, I still have a lot more practice to do before I feel fully comfortable with the framework.
This morning our MEAN Stack and Web socket lab was due. I decided to work on something simple in order to help me get a better understanding of the technologies used, so I worked on a game of tic tac toe. Web sockets are pretty fascinating, and I hope to incorporate them into a few future projects.
So far, the game doesn’t do everything that I’d like it to do. I haven’t used the database to persist the game data, so that’s one thing to add to my ‘to do’ list. I’d also like to add the following:
- Prompting the user for their name
- When users chat, having their names appear beside any remark made
The rest of the day we did a code review of a React to do list application. React definitely seems a little easier than Angular to pick up, but I find myself wanting to spend a good chunk of time to building and piecing apart applications in order to get a better understanding of Angular as well as React.
We have a three day weekend coming up, which will be perfect for me to start working on more Angular tutorials and getting more comfortable with some of the concepts that we haven’t had much time to cover in class.
Today we reviewed some of the differences and problems solved with ES6 when compared to ES5. The class broke up into teams that worked on lesson plans for different ES6 topics. My group focused on getters and setters and template literals. Both seemed pretty interesting – you can see the lesson plan we created here.
Later we reviewed React JS. From the brief introduction we received, I can tell already that I really like React’s error messages – they’re not as cryptic as Angular’s errors. Yet again, we only glazed over a few things, so this weekend I hope to delve deeper into it.