Professional Documents
Culture Documents
Why React?
1. Flexibility:
One of the main attractions to REACT is that, ONCE you learn it, you can build user interfaces for a huge
number of platforms and use cases. REACT is extremely flexible!
REACT is HIGHLY versatile because the RENDER is separate from REACT itself.
Server-side Rendering:
ReactDomServer.renderToString(): This is an example that renders a component to a string of HTML
REACT is a light-weight Library that makes it easy to update existing Apps (even server side render apps)
2. Developer Experience
The RAPID feedback development experience + Small logical API, gives a development experience that's
very hard to beat. Few concepts to master, so REACT is a tool that developers don't need to check the
docs often.
With REACT, we will be writing basically functions that return what looks like HTML. We simply import
REACT using a standard JS import statement THEN we declare a component using a regular JS function
that takes in variables via an object called PROPs…
We can also write JS Classes, which involves a bit more typing, but offers slightly more power
The markup that should sit inside our elements can contains calls to other elements if we have nested
markup. We can 100% avoid JSX, but clearly the top example is simpler to read and nest (most
commonly used by REACT developers).
Summary: Traditional Libraries put fake Javascript in HTML vs REACT which puts fake HTML in Javascript
1. Use: create-react-app
a. Single command: NPM start we can start a simple REACT app in our machine ready for
development
b. EACH COMPONENT IS ATOMIC: it stands alone
c. Every time we save, changes are immediately reflected in the browser
d. If we make a simple html mistake (like closing a tag) within JSX, we get a compile time msg
with the precise line where we made a mistake.
e. Debugging is also nicely handled:
i.
3. Corporate Investment
Created and maintained by Facebook. But REACT is Open Source though. Because of Facebook DEEP
commitment to keeping REACT stable on production when breaking changes occur in REACT, Facebook
consistently provides a codemod that automates the change. Command line tool that will automate the
change in our code.
4. Community
5. Performance
When REACT was created, one of the main elements that distinguish it from the competition is how fast
and efficient it was. REACT developers were aware that JS was fast, but it's de DOM that makes it feel
slow. Updating the DOM is expensive… so they started the use of the Virtual DOM.
6. Testability
1. Framework vs Library
Frameworks contains more opinions, so we will avoid spending time trying to choose between many options… which reduces fatigues and has less setup overhead. Not to mention more
consistency…
REACT on the other hand is significantly smaller than most frameworks. This allows us to sprinkle REACT components on existing applications without worrying about cluttering our
codebase. REACT allows you to only pull in the feature that you need to keep the app lean and fast to prioritize performance.
2. Concise vs Explicit
With REACT we control what should happen on EVERY event. This means we can TRANSFORM and VALIDATE inputs before updating STATE and perform PERFORAMNCE optimizations as
desired. We end up having to write more explicit code, but it helps with debugging.
Note that you can write single change handlers for an entire form. No need to write a handler PER input field!
Conditionals:
Loops:
Events:
5. Standard vs Non-Standard
REACT is one of many non-standard component libraries out there.
https://caniuse.com/
6. Community vs Corporate
React - The Big Picture Page 11
6. Community vs Corporate
3. Version Conflicts
We CAN'T run 2 version of REACT at the same time on the same page. This means we have to keep
REACT components on the same version throughout.
Many Resources is great no? well, some of that content is outdated. So when searching the web for
REACT topics we have to be careful not to run into patterns that are no longer popular today.
5. Decision Fatigue
REACT is a small non-opinionated library, so it is quite easy to do the same thing in multiple ways.
• Dev Environment
○ >100 boiler plates for starting REACT projects.
Some of these are limited though. For instance the popular create-react-app does not
include tools like React Router (Routing) OR Redux (State Management)
• Types
○ PropTypes
With PropTypes Types are checked at run time and ONLY during development
○ TypeScript
Super set of Javascript
○ Flow
You add type annotations to plain JS and flows infers types throughout our codebase
You annotate the files we want to be checked
• State Management
○ State: Our App's Data
○ Plain REACT, Flux, Redux and MobX
• Styling
○ Use whatever you know today. REACT works great with CSS, SCSS, etc…