Please enable JavaScript.
Coggle requires JavaScript to display documents.
React In Action & JS (Chapter 2 (React Elements Properties (Structure:…
React In Action & JS
Chapter 2
-
What is an API?
An API, or, application programming interface, is a set of routines and protocols for building software.
RESTful JSON API. This means that a server will give you data in the JSON format and the available data organized around resources like users, posts, comments, and so on.
-
-
You need to provide some sort of way to validate which properties you’ll be using so you can prevent bugs and plan the sorts of data your components will use.
The PropTypes set of validators used to be included with the React core library, but was later broken out and deprecated within React in version 15.5. To use PropTypes, you’ll need to install the proptypes package, which is still part of the React toolchain but is no longer included in the core library.
Chapter 1
“my wager is that a robust mental model and deep understanding coupled with practical examples will put you in a place to do incredible things with React, whether on your own or with others.”
Excerpt From: Mark Tielens Thomas. “React in Action.” Apple Books.
getElementById, parent.appendChild, querySelectorAll, innerHTML
-
Virtual DOM
-
When data changes, we want to update the UI to reflect that. Doing that in a way that’s efficient and easy to think about can be difficult, so React aims to solve that problem.
-
-
-
Official Tutorial
Notes
In JavaScript classes, you need to always call super when defining the constructor of a subclass. All React component classes that have a constructor should start it with a super(props) call.
Forgetting () => and writing onClick={alert('click')} is a common mistake, and would fire the alert every time the component re-renders.
We split the returned element into multiple lines for readability, and added parentheses so that JavaScript doesn’t insert a semicolon after return and break our code.
Eloquent JavaScript
-
Chapter 3 Function
-
Arrow function
If there is only one parameter, you can omit the parentheses around the parameter list.
When there is only one expression, you can easily omit the return and braces.
A function will ignore the extra parameter, and set the missing parameters to undefined
.
-
The returned function can contain new parameter, and will be usable anytime in that function.
-
Nested function is possible in JS, and is very handy for recursion, etc.
-
-
Pick out a single concept for function name, instead of a wholesale...
-
-
Chapter 1 Values, Types, and Operators
", ', and ` can all be used for strings
-
-
-
-
-
-
C6 Object
-
It is also common to put an underscore (_) character at the start of property names to indicate that those properties are private.
this
Method 1: object.method()
Here this
represents the calling object, and can be accessed in the 'method()'
Method 2: method.call(object, ...)
here we call the function with object to be the first parameter, and then we can access this object in the method()
with this
too.
-
-
-