Download - Presentation react

Transcript
Page 1: Presentation react

Hamza

@ham_ism

React.js For Humans

@[email protected]

Oran tech meetup - March 4th, 2017

Page 2: Presentation react
Page 3: Presentation react

We’ve got stickers

Page 4: Presentation react

• What is react • React Element • React Component • State & props • Proptypes • JSX • Lifecycle Hooks • Presentational & container components

Table of Content

Page 5: Presentation react

React is a library for building user interfaces.

What is React

Page 6: Presentation react

React.js

Ember.js

Angular.js 2

Angular.js 1

Stats

Page 7: Presentation react

f(d) = v

d = state,props

What is React

Page 8: Presentation react

React Element

Once react element is rendered it can’t be updated (it represents the state of UI at a given time).

Is a plain object representation of a DOM node.Is not what you are going to see in the screen.Can be composed of other react components.

Page 9: Presentation react

Reconciliation is the process of generating an object representation of the DOM and is performed :

React Element

Every time setState or ReactDOM.render is called.

When the state changes the react component is re-rendered (thanks Virtual DOM)

Page 10: Presentation react

Components are the building blocks for react.

A component is a class or a function that optionally accepts input and returns a react element.

If a component is a function then it is stateless(has no state and no event hooks).

React Component

Page 11: Presentation react

State & props

State : data that is associated with the componentProps : variables passed from the parent to the component

Page 12: Presentation react

Proptypes

Enforce properties type.

Page 13: Presentation react

JSX is always going to get transpiled to React.createElement invocations via babel JSX is only an abstraction over React.createElement

JSX

JSX is simply a Javascript code with the declarativeness and familiarity of HTML

Page 14: Presentation react

React.createElement( "div", null, React.createElement( "p", null, "Hello There" ) );

<div> <p>Hello There</p> </div> JSX Transpiler

(babel REPL)

JSX

Page 15: Presentation react

constructorcomponentWillMountrendercomponentDidMountblabla…

componentWillUnmount

Lifecycle Hooks(events)

Page 16: Presentation react

Presentational & container components(smart & dumb)

When you Have different concerns it is time to split

Page 17: Presentation react

Questions

?

Page 18: Presentation react

https://www.reddit.com/r/reactjs/comments/5gmywc/what_were_the_biggest_aha_moments_you_had_whilehttps://facebook.github.io/react/blog/2015/12/18/react-components-elements-and-instances.html

https://facebook.github.io/react

https://www.youtube.com/watch?v=kp-NOggyz54https://egghead.io/courses/getting-started-with-redux

https://medium.com/@learnreact/container-components-c0e67432e005#.kjold6xbv

https://github.com/facebookincubator/create-react-app

Resources


Top Related