React: Difference between revisions

1,428 bytes added ,  9 October 2019
add personal blogs to references
add personal blogs to references
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
Notes from Learning React, 2nd Edition by Porcello & Banks
Notes from '''Learning React, 2nd Edition''' by Porcello & Banks and other sources


= Installation =
= Installation =
Line 86: Line 86:


== Arrow functions and scope ==
== Arrow functions and scope ==
Reference
* [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions Arrow functions]
* [https://www.codementor.io/dariogarciamoya/understanding-this-in-javascript-with-arrow-functions-gcpjwfyuc Understanding "this" in javascript with arrow functions]


<source lang="js">
<source lang="js">
Line 116: Line 123:
tahoe.print(); // Freel, Rose, Tallac, Rubicon, Silver
tahoe.print(); // Freel, Rose, Tallac, Rubicon, Silver
</source>
</source>


== Destructing objects ==
== Destructing objects ==
Line 259: Line 265:


== Spread operator ==
== Spread operator ==
Reference: [https://github.com/tc39/proposal-object-rest-spread Object Rest/Spread Properties for ECMAScript]


<source lang="js">
<source lang="js">
Line 327: Line 335:
// }
// }
</source>
</source>


== Asynchronous requests ==
== Asynchronous requests ==
Line 1,676: Line 1,683:


== React fragments ==
== React fragments ==
<source lang="js">
function Cat({ name }) {
  return (
    <React.Fragment>
      <h1>The cat's name is {name}</h1>
      <p>He's good.</p>
    </React.Fragment>
  );
}
// equivalent to
function Cat({ name }) {
  return (
    <>
      <h1>The cat's name is {name}</h1>
      <p>He's good.</p>
    </>
  );
}
</source>
== Intro to webpack ==
* Code splitting
* Minification
* Feature flagging
* Hot module replacement (HMR)
* Modularity
* Composition
* Speed
* Consistency
Installing webpack
<source lang="console">
$ npm install --save-dev webpack@next webpack-cli
</source>
Installing Babel dependencies
<source lang="console">
$ npm install babel-loader @babel/core --save-dev
</source>
Specify Babel presets
<source lang="console">
$ npm install @babel/preset-env @babel/preset-react --save-dev
</source>


= React State Management =
= React State Management =
= Reference =
* [https://react-icons.netlify.com React Icons]
* Personal blogs
** [https://www.leighhalliday.com Leigh Halliday]
** [https://www.robinwieruch.de Robin Wieruch]