Wait, but what exactly is React?
Benjamin Liu
Posted on November 22, 2019
Coworkers and colleagues have been asking me about React since 2014. Instead of explaining it time and time again, I will give my 5-minute summary here in this article.
What is React?
React is a JavaScript library developed by Jordan Walke, a software engineer at Facebook back in 2011. Since then, React has become a widely popular open-source library that is used by Facebook, Instagram, Netflix, PayPal (just to name a few) and maintained by Facebook, Instagram and an amazing community of developers that have taken an interest in the library.
How does React work?
React uses a component based architecture (i.e. it involves you writing "components"), defined using a special JSX syntax which compiles down into regular JavaScript. Here we have a Button
component that renders a different class name to the <button>
based on the props.
const Button = props => {
const className = `button ${props.type}`;
return (
<button className={className} onClick={props.handleClick}>
{props.label}
</button>
);
};
This level of flexibility makes creating interactive UIs fun as you are able to reuse components in different parts of your webpage.
Note: Although the code within the return
looks like valid HTML, it JSX - a syntax extension to JavaScript to make defining React elements easier.
When you want to render a particular kind of button, you just pass the <Button>
component a list of props (similar to attributes in HTML):
<div className="app">
<Button handleClick={handleAPICall} label="Submit" type="primary" />
</div>
Why should I learn React?
- It's incredibly popular, and as such is very employable. A survey conducted by Stack Overflow showed that React was the most loved and wanted web framework.
- It's incredibly fun. IMHO what makes React so great and so popular is the fact that it is not restrictive. It does so much yet has so few constraints, that using it feels just like magic.
- Do you have another reason? Let's discuss it below in the comments! Thanks for reading!
Posted on November 22, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.