Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

React JSX: Building User Interfaces with Components and State, Summaries of Combinatorics

React jsx, a syntax used to build user interfaces in react. It covers the basics of components, props, state, and rendering markup. Examples include a hellomessage component, a timer component, and a todo application.

Typology: Summaries

2012/2013

Uploaded on 08/11/2021

first-last-26
first-last-26 🇮🇳

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
JS
X
?
A S
i
mp
le
C
ompon
e
nt
R
eac
t
c
ompon
e
nts
i
mp
le
m
e
nt
a
render()
m
e
t
h
o
d
t
ha
t
t
ake
s
i
nput
da
t
a
a
n
d
r
e
turns
w
ha
t
to
di
sp
la
y
.
T
hi
s
e
x
a
mp
le
us
e
s
a
n
X
ML
-
like
synt
a
x
called
JS
X
.
I
nput
da
t
a
t
ha
t
i
s
p
a
ss
ed
i
nto
t
he
c
ompon
e
nt
ca
n
be
acce
ss
ed
b
y
render()
v
ia
this.props
.
JS
X
i
s
opt
i
on
al
a
n
d
not
r
e
qu
i
r
ed
to
us
e
R
eac
t
.
T
ry
t
he
B
abel
REPL
to
s
ee
t
he
r
a
w
J
a
v
a
S
c
r
i
pt
c
o
de
pro
d
u
ced
b
y
t
he
JS
X
c
omp
ila
t
i
on
st
e
p
.
LI
V
E JS
X
EDITOR
class HelloMessage extends React.Component {
render() {
return (
<div>
R
eac
t
A J
a
v
a
S
c
r
i
pt
lib
r
a
ry
f
or
b
u
ildi
n
g
us
e
r
i
nt
e
r
face
s
G
e
t
S
t
a
rt
ed
T
ake
t
he
T
utor
ial
D
ecla
r
a
t
i
v
e
R
eac
t
m
ake
s
i
t
p
ai
n
le
ss
to
c
r
ea
t
e
i
nt
e
r
ac
t
i
v
e
U
I
s
.
D
e
s
ig
n
s
i
mp
le
v
ie
ws
f
or
each
st
a
t
e
i
n
your
a
pp
lica
t
i
on
,
a
n
d
R
eac
t
w
ill
efficie
nt
l
y
up
da
t
e
a
n
d
r
e
n
de
r
j
ust
t
he
r
igh
t
c
ompon
e
nts
w
he
n
your
da
t
a
cha
n
ge
s
.
D
ecla
r
a
t
i
v
e
v
ie
ws
m
ake
your
c
o
de
mor
e
pr
edic
t
able
a
n
d
ea
s
ie
r
to
deb
u
g
.
C
ompon
e
nt
-
B
a
s
B
u
ild
e
n
ca
psu
la
t
ed
c
ompos
e
t
he
m
to
m
S
i
n
ce
c
ompon
e
nt
l
o
you
ca
n
ea
s
il
y
p
a
ss
t
he
DOM
.
D
ecla
r
a
t
i
v
e
R
eac
t
m
ake
s
i
t
p
ai
n
le
ss
to
c
r
ea
t
e
i
nt
e
r
ac
t
i
v
e
U
I
s
.
D
e
s
ig
n
s
i
mp
le
v
ie
ws
f
or
each
st
a
t
e
i
n
your
a
pp
lica
t
i
on
,
a
n
d
R
eac
t
w
ill
efficie
nt
l
y
up
da
t
e
a
n
d
r
e
n
de
r
j
ust
t
he
r
igh
t
c
ompon
e
nts
w
he
n
your
da
t
a
cha
n
ge
s
.
D
ecla
r
a
t
i
v
e
v
ie
ws
m
ake
your
c
o
de
mor
e
pr
edic
t
able
a
n
d
ea
s
ie
r
to
deb
u
g
.
C
ompon
e
nt
-
B
a
s
B
u
ild
e
n
ca
psu
la
t
ed
c
ompos
e
t
he
m
to
m
S
i
n
ce
c
ompon
e
nt
l
o
you
ca
n
ea
s
il
y
p
a
ss
t
he
DOM
.
pf3
pf4

Partial preview of the text

Download React JSX: Building User Interfaces with Components and State and more Summaries Combinatorics in PDF only on Docsity!

JSX?

A Simple Component

React components implement a render() method that takes input data and returns what to display. This example uses an XML-like syntax called JSX. Input data that is passed into the component can be accessed by render() via this.props. JSX is optional and not required to use React. Try the Babel REPL to see the raw JavaScript code produced by the JSX compilation step. LIVE JSX EDITOR class HelloMessage extends React.Component { render() { return (

React

A JavaScript library for building user interfaces Get Started Take the Tutorial

Declarative

React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes. Declarative views make your code more predictable and easier to debug.

Component-Bas

Build encapsulated compose them to m Since component lo you can easily pass the DOM.

Declarative

React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes. Declarative views make your code more predictable and easier to debug.

Component-Bas

Build encapsulated compose them to m Since component lo you can easily pass the DOM.

JSX? Hello {this.props.name}

); } } ReactDOM.render( , document.getElementById('hello-example') ); **RESULT** Hello Taylor

A Stateful Component

In addition to taking input data (accessed via this.props ), a component can maintain internal state data (accessed via this.state ). When a componentʼs state data changes, the rendered markup will be updated by re-invoking render(). LIVE JSX EDITOR RESULT Seconds: 1 class Timer extends React.Component { constructor(props) { super(props); this.state = { seconds: 0 }; } tick() { this.setState(state => ({ seconds: state.seconds + 1 })); } componentDidMount() { this.interval = setInterval(() => this.tick(), 1000 ); } () {

JSX? React allows you to interface with other libraries and frameworks. This example uses remarkable , an external Markdown library, to convert the