These are my reading notes for Code Fellows
Note: I accidentally read all of the Intro to React page for Read 01. My notes for that particular reading can be found in the day 1 reading here.
state
is like props
but remains inside of a component. They are local (AKA top-down/unidirectional)
In React, “mounting” is when an element is initially inserted into the DOM. The reading uses an example of a timer that is set up whenever the Constructor Clock
is rendered. “Unmounting” is when that timer is removed.
use this.setState
syntax instead of this.state
setState
works just as well with functions as it does with arrow functions
Events are similar with React, but the syntax differs
Same functionality in HTML vs React:
<button onclick="setName()">
<button onClick={setName}>
In React, you don’t need to use addEventListener
to DOM elements, just when it’s first rendered
The reading shows a really slick way of displaying whether a user is signed into their website or not (displaying corresponding ‘welcome’ messages). It uses a prop named isLoggedIn
that can either be true or false. These can be easily tied to buttons that log a user in and out
The reading also utilizes a falsy expression to achieve a particular goal (in this case, a certain number of unread messages)