SlideShare a Scribd company logo
Uvod u React
03/11/2016
Goran Gajic
twitter.com/golenull
github.com/gorangajic
Deklarativan
Opišete kako vaš interfejs izgleda i u svakom
trenutku tako će i izgledati
Bazira se na Komponentama
- Kockice za pravljenje vase aplikacije
- Lako se sklapaju
- Jednostavno se koriste
- Izmene su lakse, zato sto su promene
izolovane po komponentama
Dostupan
- Radi u vasoj postojećoj aplikaciji
- Radi na serveru
- Uz pomoć react-native pišete mobilne
aplikacije
JSX
- JSX je nadogradnja na JavaScript
- Sva moć JavaScripta, bez uvođenja novog jezika
- Nije neophodan, ali olakšava posao
- Ponaša se kao i HTML, JSX ima ime taga, attribute i
svoju decu.
JSX
class Hello extends React.Component {
render() {
return <h1> Hello World </h1>;
}
}
class Hello extends React.Component {
render() {
return React.createElement(
"h1", null, "Hello World"
);
}
}
rendering
class Message extends React.Component {
render() {
return (<div className="message">
<Avatar username={this.props.user} size="large" />
<ChatMessage>
{this.props.message}
</ChatMessage>
</div>);
}
}
state
class Hello extends React.Component {
constructor(props) {
super(props);
this.state = {
open: false,
}
}
componentDidMount() {
this.setState({ open: true });
}
...
props
class Chat extends React.Component {
...
render() {
return (<div className="chat">
<MessagesList messages={this.state.messages} />
<ChatInput onChange={(message) => this.addMessage(message)} />
</div>);
}
....
}
Events
class ChatInput extends React.Component {
render() {
return (<div className="form-inline">
<input
value={this.state.message}
onChange={(e) => this.setState({ message: e.target.value })}
/>
<button onClick={() => this.saveMessage()}>
Send
</button>
</div>);
}
}
React DOM
Biblioteka koja je zadužena za prikaz vaših komponenti na stranici
ReactDOM.render(
<App />,
document.getElementById('root')
);
Alati
- Node.js
- npm
- Babel
- Webpack
Create react app
npm install -g create-react-app
create-react-app moja-aplikacija
cd moja-aplikacija/
npm start
Demo

More Related Content

What's hot

Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
Rasheed Waraich
 
React js programming concept
React js programming conceptReact js programming concept
React js programming concept
Tariqul islam
 
Spring Framework - Spring Security
Spring Framework - Spring SecuritySpring Framework - Spring Security
Spring Framework - Spring Security
Dzmitry Naskou
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
Santosh Kumar Kar
 
Spring Boot
Spring BootSpring Boot
Spring Boot
Jaran Flaath
 
Spring Security 5
Spring Security 5Spring Security 5
Spring Security 5
Jesus Perez Franco
 
Spring Boot & WebSocket
Spring Boot & WebSocketSpring Boot & WebSocket
Spring Boot & WebSocket
Ming-Ying Wu
 
ReactJS
ReactJSReactJS
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
Dzmitry Naskou
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
Jeevesh Pandey
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
07.pallav
 
React lecture
React lectureReact lecture
React lecture
Christoffer Noring
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introduction
Jonathan Holloway
 
Important React Hooks
Important React HooksImportant React Hooks
Important React Hooks
Knoldus Inc.
 
React.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOMReact.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOM
Jimit Shah
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
Naphachara Rattanawilai
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
Alex Movila
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developers
Patrick Savalle
 
Ngrx slides
Ngrx slidesNgrx slides
Ngrx slides
Christoffer Noring
 
Spring Boot
Spring BootSpring Boot
Spring Boot
Jiayun Zhou
 

What's hot (20)

Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
React js programming concept
React js programming conceptReact js programming concept
React js programming concept
 
Spring Framework - Spring Security
Spring Framework - Spring SecuritySpring Framework - Spring Security
Spring Framework - Spring Security
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring Security 5
Spring Security 5Spring Security 5
Spring Security 5
 
Spring Boot & WebSocket
Spring Boot & WebSocketSpring Boot & WebSocket
Spring Boot & WebSocket
 
ReactJS
ReactJSReactJS
ReactJS
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
 
React lecture
React lectureReact lecture
React lecture
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introduction
 
Important React Hooks
Important React HooksImportant React Hooks
Important React Hooks
 
React.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOMReact.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOM
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developers
 
Ngrx slides
Ngrx slidesNgrx slides
Ngrx slides
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 

Uvod u react

  • 1. Uvod u React 03/11/2016 Goran Gajic twitter.com/golenull github.com/gorangajic
  • 2. Deklarativan Opišete kako vaš interfejs izgleda i u svakom trenutku tako će i izgledati
  • 3. Bazira se na Komponentama - Kockice za pravljenje vase aplikacije - Lako se sklapaju - Jednostavno se koriste - Izmene su lakse, zato sto su promene izolovane po komponentama
  • 4. Dostupan - Radi u vasoj postojećoj aplikaciji - Radi na serveru - Uz pomoć react-native pišete mobilne aplikacije
  • 5. JSX - JSX je nadogradnja na JavaScript - Sva moć JavaScripta, bez uvođenja novog jezika - Nije neophodan, ali olakšava posao - Ponaša se kao i HTML, JSX ima ime taga, attribute i svoju decu.
  • 6. JSX class Hello extends React.Component { render() { return <h1> Hello World </h1>; } } class Hello extends React.Component { render() { return React.createElement( "h1", null, "Hello World" ); } }
  • 7. rendering class Message extends React.Component { render() { return (<div className="message"> <Avatar username={this.props.user} size="large" /> <ChatMessage> {this.props.message} </ChatMessage> </div>); } }
  • 8. state class Hello extends React.Component { constructor(props) { super(props); this.state = { open: false, } } componentDidMount() { this.setState({ open: true }); } ...
  • 9. props class Chat extends React.Component { ... render() { return (<div className="chat"> <MessagesList messages={this.state.messages} /> <ChatInput onChange={(message) => this.addMessage(message)} /> </div>); } .... }
  • 10. Events class ChatInput extends React.Component { render() { return (<div className="form-inline"> <input value={this.state.message} onChange={(e) => this.setState({ message: e.target.value })} /> <button onClick={() => this.saveMessage()}> Send </button> </div>); } }
  • 11. React DOM Biblioteka koja je zadužena za prikaz vaših komponenti na stranici ReactDOM.render( <App />, document.getElementById('root') );
  • 12. Alati - Node.js - npm - Babel - Webpack
  • 13. Create react app npm install -g create-react-app create-react-app moja-aplikacija cd moja-aplikacija/ npm start
  • 14. Demo