Section 1

Preview this deck

React Node Factories

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (31)

Section 1

(31 cards)

React Node Factories

Front

A function that generates a React element node with a particular type property.

Back

Props State diff

Front

props (short for "properties") and state are both plain JavaScript objects. While both hold information that influences the output of render, they are different in one important way: props get passed to the component (similar to function parameters) whereas state is managed within the component (similar to variables declared within a function). Props and state are related. The state of one component will often become the props of a child component. Props are passed to the child within the render method of the parent as the second argument to React.createElement() or, if you're using JSX, the more familiar tag attributes. <MyChild name={this.state.childsName} /> The parent's state value of childsName becomes the child's this.props.name. From the child's perspective, the name prop is immutable. If it needs to be changed, the parent should just change its internal state: this.setState({ childsName: 'New name' }); and React will propagate it to the child for you. A natural follow-on question is: what if the child needs to change its name prop? This is usually done through child events and parent callbacks. The child might expose an event called, for example, onNameChanged. The parent would then subscribe to the event by passing a callback handler. <MyChild name={this.state.childsName} onNameChanged={this.handleName} /> The child would pass its requested new name as an argument to the event callback by calling, e.g., this.props.onNameChanged('New name'), and the parent would use the name in the event handler to update its state. handleName: function(newName) { this.setState({ childsName: newName }); } https://stackoverflow.com/questions/27991366/what-is-the-difference-between-state-and-props-in-react

Back

Component class

Front

It has a state, lifecycle hooks and it is a javascript class which means that React creates instances of it. React should initialise the component class in order to call lifecycle hooks, call a constructor, initialise state and more.

Back

Webpack

Front

Webpack is a module loader and bundler that takes modules (.js, .css, .txt, etc.) with dependencies and generates static assets representing these modules. Need to take a few steps back and figure out what is react javascript and how you can use it?

Back

ES5

Front

The 5th edition of the ECMAScript standard. The ECMAScript 5.1 edition was finalized in June 2011.

Back

ECMAScript 2016 (a.k.a, ES7)

Front

The 7th edition of the ECMAScript standard. The ECMAScript 7th edition was finalized in June 2016.

Back

stateless functional component

Front

A functional(a.k.a. stateless) component is just a plain javascript function which takes props as an argument and returns a react element. A stateless component has no state(obvious, isn't it?), it means that you can't reach `this.state` inside it. It also has no lifecycle so you can't use componentDidMount and other hooks.

Back

Why bind

Front

When you define a component using an ES6 class, a common pattern is for an event handler to be a method on the class. In JavaScript, class methods are not bound by default. If you forget to bind this.someEventHandler and pass it to onChange, this will be undefined when the function is actually called.

Back

React Attributes/Props

Front

In one sense you can think of props as the configuration options for React nodes and in another sense you can think of them as HTML attributes. Props take on several roles: Props can become HTML attributes. If a prop matches a known HTML attribute then it will be added to the final HTML element in the DOM. Props passed to createElement() become values stored in a prop object as an instance property of React.createElement() instances (i.e., [INSTANCE].props.[NAME OF PROP]). Props by and large are used to input values into components. A few special props have side effects (e.g., key, ref, and dangerouslySetInnerHTML)

Back

ES6/ES 2015

Front

The 6th edition of the ECMAScript standard. A.k.a, JavaScript 2015 or ECMAScript 2015. The ECMAScript 6th edition was finalized in June 2015.

Back

React

Front

React is an open source JavaScript library for writing declarative, efficient, and flexible user interfaces.

Back

React Element Nodes (a.k.a., ReactElement)

Front

An HTML or custom HTML element node representation in the Virtual DOM created using React.createElement();.

Back

ES6 Destructuring

Front

const HelloStateless = ({firstName, version}) => ( <div> <h1>Hello {firstName}</h1> <p>Learning Reaction Version {version}</p> </div> )

Back

Document Object Model

Front

"The Document Object Model (DOM) is a programming interface for HTML, XML and SVG documents. It provides a structured representation of the document as a tree. The DOM defines methods that allow access to the tree, so that they can change the document structure, style and content. The DOM provides a representation of the document as a structured group of nodes and objects, possessing various properties and methods. Nodes can also have event handlers attached to them, and once an event is triggered, the event handlers get executed. Essentially, it connects web pages to scripts or programming languages." - MSD

Back

Refs

Front

https://hackernoon.com/refs-in-react-all-you-need-to-know-fb9c9e2aeb81

Back

Node.js

Front

Node.js is an open-source, cross-platform runtime environment for writing JavaScript. The runtime environment interprets JavaScript using Google's V8 JavaScript engine.

Back

React Text Nodes (a.k.a., ReactText)

Front

A text node representation in the Virtual DOM created using React.createElement('div',null,'a text node');.

Back

Constructor

Front

Responsible for initializing state

Back

Babel

Front

Babel transforms JavaScript ES (i.e., JS 2016, 2016, 2017) to ES5. Babel is the tool of choice from the React team for writing future ES code and transforming JSX to ES5 code.

Back

What's the difference between "super()" and "super(props)" in React when using es6 classes?

Front

516 There is only one reason when one needs to pass props to super(): When you want to access this.props in constructor. Passing: class MyComponent extends React.Component { constructor(props) { super(props) console.log(this.props) // -> { icon: 'home', ... } } } Not passing: class MyComponent extends React.Component { constructor(props) { super() console.log(this.props) // -> undefined // Props parameter is still available console.log(props) // -> { icon: 'home', ... } } render() { // No difference outside constructor console.log(this.props) // -> { icon: 'home', ... } } } Note that passing or not passing props to super has no effect on later uses of this.props outside constructor. That is render, shouldComponentUpdate, or event handlers always have access to it. This is explicitly said in one Sophie Alpert's answer to a similar question. ======= If you use super(props), you can call methods that use this.props in from constructor, like this.doStuffUsingThisDotProps(), without having to pass on the props parameter to those methods/functions. I just wrote a constructor doing this, which seemingly would require me to use super(props)

Back

Component Configuration Options

Front

(a.k.a, "Component Specifications") The configuration arguments passed (as an object) to the React.createClass() function resulting in an instance of a React component.

Back

ES*

Front

Used to represent the current version of JavaScript as well as potential future versions that can written today using tools like Babel. When you see "ES*" it more than likely means you'll find uses of ES5, ES6, and ES7 together.

Back

bind this

Front

https://medium.freecodecamp.org/react-binding-patterns-5-approaches-for-handling-this-92c651b5af56

Back

React Stateless Function Component

Front

When a component is purely a result of props alone, no state, the component can be written as a pure function avoiding the need to create a React component instance. var MyComponent = function(props){ return <div>Hello {props.name}</div>; }; ReactDOM.render(<MyComponent name="doug" />, app);

Back

React Nodes

Front

React nodes (i.e., element and text nodes) are the primary object type in React and can be created using React.createElement('div');. In other words React nodes are objects that represent DOM nodes and children DOM nodes. They are a light, stateless, immutable, virtual representation of a DOM node.

Back

React Component

Front

A React component is created by calling React.createClass() (or, React.Component if using ES6 classes). This function takes an object of options that is used to configure and create a React component. The most common configuration option is the render function which returns React nodes. Thus, you can think of a React component as an abstraction containing one or more React nodes/components.

Back

Virtual DOM

Front

An in-memory JavaScript tree of React elements/components that is used for efficient re-rendering (i.e., diffing via JavaScript) of the browser DOM.

Back

JSX

Front

JSX is an optional XML-like syntax extension to ECMAScript that can be used to define an HTML-like tree structure in a JavaScript file. The JSX expressions in a JavaScript file must be transformed to JavaScript syntax before a JavaScript engine can parse the file. Babel is typically used and recommended for transforming JSX expressions.

Back

Component Life Cycle Methods

Front

A sub group of component events, semantically separated from the other component configuration options (i.e., componentWillUnmount, componentDidUpdate, componentWillUpdate, shouldComponentUpdate, componentWillReceiveProps, componentDidMount, componentWillMount). These methods are executed at specific points in a component's existence.

Back

Props

Front

React

Back

npm

Front

npm is the package manager for JavaScript born from the Node.js community.

Back