SlideShare ist ein Scribd-Unternehmen logo
1 von 11
React
Brief Introduction
Maciej Litwiniuk
Prograils Lightning Talks, 10 Nov 2015
–https://facebook.github.io/react/
„A JavaScript library for building user interfaces”
It's the "V" in MVC
It's fast.
Like... really fast
Photo: Tim Shields, https://www.flickr.com/photos/glaciertim/4320524072/
Virtual DOM
Think of it like
something similar to
russian doll caching
Advantages
• Easy plug and play - even in existing, mature
application
• Can be rendered server-side
• DOM manipulation in one place
• Re-render only what needed
–Yoda
„So how to use it in Rails, you wondering must”
1 gem 'therubyracer' # it's just fast
2 # https://github.com/reactjs/react-rails/pull/290
3 gem 'react-rails', '~> 1.4.0'
1 # config/environments/development.rb
2 RewardsThem::Application.configure do
3 config.react.variant = :development
4 end
1.
2.
1 <div class="row">
2 <div class="col-lg-7 col-md-12">
3 <h3>
4 What happend recently
5 </h3>
6 <% @rewards.each do |reward| %>
7 <%= render reward %>
8 <% end %>
9 </div>
10 </div>
11
1 <div class="row">
2 <div class="col-lg-7 col-md-12">
3 <h3>
4 What happend recently
5 </h3>
6 <% @rewards.each do |reward| %>
7 <%= react_component 'Reward', reward: reward.to_json %>
8 <% end %>
9 </div>
10 </div>
11
1 class Reward extends React.Component{
2 render(){
3 const reward = this.props.reward;
4 return (
5 <div className={ this.rewardClass() }>
6 <div className="created_at">{ reward.created_at }</div>
7 <div className="description">
8 <a href={ reward.giver_path }>{ reward.giver }</a>
9 <div className="glyphicon glyphicon-arrow-right" />
10 <a href={ reward.recipient_path }>{ reward.recipient }</a>
11 <div className="border">
12 { reward.description }
13 <div className="points">{ reward.value }</div>
14 </div>
15 </div>
1 <div class="<%= reward_class(reward) %>">
2 <div class="created_at">
3 <%= reward.created_at.to_s(:short) %>
4 </div>
5 <div class="description">
6 <%= link_to reward.giver, user_path(reward.giver) %>
7 <div class="glyphicon glyphicon-arrow-right"></div>
8 <%= link_to reward.recipient, user_path(reward.recipient) %>
9 <div class="border">
10 <%= emojify reward.description %>
11 <div class="points">
12 <%= reward.value_with_unit %>
13 </div>
14 </div>
15 </div>
16 </div>

Weitere ähnliche Inhalte

Was ist angesagt?

jQuery Conference San Diego 2014 - Web Performance
jQuery Conference San Diego 2014 - Web PerformancejQuery Conference San Diego 2014 - Web Performance
jQuery Conference San Diego 2014 - Web Performance
dmethvin
 

Was ist angesagt? (20)

Frontend architecture design for large(r) team final
Frontend architecture design for large(r) team   finalFrontend architecture design for large(r) team   final
Frontend architecture design for large(r) team final
 
Bringing The Sexy Back To WebWorkers
Bringing The Sexy Back To WebWorkersBringing The Sexy Back To WebWorkers
Bringing The Sexy Back To WebWorkers
 
Lessons in Open Source from the MongooseJS ODM
Lessons in Open Source from the MongooseJS ODMLessons in Open Source from the MongooseJS ODM
Lessons in Open Source from the MongooseJS ODM
 
WebAssembly overview. KievJS meetup
WebAssembly overview. KievJS meetupWebAssembly overview. KievJS meetup
WebAssembly overview. KievJS meetup
 
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and BackboneJavascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
 
jQuery Keynote - Fall 2010
jQuery Keynote - Fall 2010jQuery Keynote - Fall 2010
jQuery Keynote - Fall 2010
 
MongoDB MEAN Stack Webinar October 7, 2015
MongoDB MEAN Stack Webinar October 7, 2015MongoDB MEAN Stack Webinar October 7, 2015
MongoDB MEAN Stack Webinar October 7, 2015
 
SGCE 2012 Lightning Talk-Single Page Interface
SGCE 2012 Lightning Talk-Single Page InterfaceSGCE 2012 Lightning Talk-Single Page Interface
SGCE 2012 Lightning Talk-Single Page Interface
 
Testing Mobile JavaScript
Testing Mobile JavaScriptTesting Mobile JavaScript
Testing Mobile JavaScript
 
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products te...
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products te...Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products te...
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products te...
 
Testing Mobile JavaScript (Fall 2010
Testing Mobile JavaScript (Fall 2010Testing Mobile JavaScript (Fall 2010
Testing Mobile JavaScript (Fall 2010
 
Javascript Frameworks Comparison
Javascript Frameworks ComparisonJavascript Frameworks Comparison
Javascript Frameworks Comparison
 
Webpack
WebpackWebpack
Webpack
 
Node PDX: Intro to Sails.js
Node PDX: Intro to Sails.jsNode PDX: Intro to Sails.js
Node PDX: Intro to Sails.js
 
jQuery Conference San Diego 2014 - Web Performance
jQuery Conference San Diego 2014 - Web PerformancejQuery Conference San Diego 2014 - Web Performance
jQuery Conference San Diego 2014 - Web Performance
 
ITT Flisol 2013
ITT Flisol 2013ITT Flisol 2013
ITT Flisol 2013
 
On Selecting JavaScript Frameworks (Women Who Code 10/15)
On Selecting JavaScript Frameworks (Women Who Code 10/15)On Selecting JavaScript Frameworks (Women Who Code 10/15)
On Selecting JavaScript Frameworks (Women Who Code 10/15)
 
WebKit Programming in Cocoa
WebKit Programming in CocoaWebKit Programming in Cocoa
WebKit Programming in Cocoa
 
Get Hip with JHipster - Denver JUG 2015
Get Hip with JHipster - Denver JUG 2015Get Hip with JHipster - Denver JUG 2015
Get Hip with JHipster - Denver JUG 2015
 
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Angular Summit 2015
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Angular Summit 2015Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Angular Summit 2015
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Angular Summit 2015
 

Ähnlich wie React brief introduction

Dynamic Languages & Web Frameworks in GlassFish
Dynamic Languages & Web Frameworks in GlassFishDynamic Languages & Web Frameworks in GlassFish
Dynamic Languages & Web Frameworks in GlassFish
IndicThreads
 

Ähnlich wie React brief introduction (20)

LA RubyConf 2009 Waves And Resource-Oriented Architecture
LA RubyConf 2009 Waves And Resource-Oriented ArchitectureLA RubyConf 2009 Waves And Resource-Oriented Architecture
LA RubyConf 2009 Waves And Resource-Oriented Architecture
 
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
 
Create a module bundler from scratch
Create a module bundler from scratchCreate a module bundler from scratch
Create a module bundler from scratch
 
Introduction to Apache Roller
Introduction to Apache RollerIntroduction to Apache Roller
Introduction to Apache Roller
 
Leaner microservices with Java 10
Leaner microservices with Java 10Leaner microservices with Java 10
Leaner microservices with Java 10
 
Jaoo Michael Neale 09
Jaoo Michael Neale 09Jaoo Michael Neale 09
Jaoo Michael Neale 09
 
3d web
3d web3d web
3d web
 
2016-05-12 DCRUG React.rb
2016-05-12 DCRUG React.rb2016-05-12 DCRUG React.rb
2016-05-12 DCRUG React.rb
 
MidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
MidwestJS 2014 Reconciling ReactJS as a View Layer ReplacementMidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
MidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
 
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
 
Why you should add React to your Rails application now!
Why you should add React to your Rails application now!Why you should add React to your Rails application now!
Why you should add React to your Rails application now!
 
Workshop Framework(J2EE/OSGi/RCP)
Workshop Framework(J2EE/OSGi/RCP)Workshop Framework(J2EE/OSGi/RCP)
Workshop Framework(J2EE/OSGi/RCP)
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Lightning Web Component in Salesforce
Lightning Web Component in SalesforceLightning Web Component in Salesforce
Lightning Web Component in Salesforce
 
Building reusable components as micro frontends with glimmer js and webcompo...
Building reusable components as micro frontends  with glimmer js and webcompo...Building reusable components as micro frontends  with glimmer js and webcompo...
Building reusable components as micro frontends with glimmer js and webcompo...
 
DotNet MVC and webpack + Babel + react
DotNet MVC and webpack + Babel + reactDotNet MVC and webpack + Babel + react
DotNet MVC and webpack + Babel + react
 
Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and Gaelyk
 
Top 8 Ruby on Rails Gems
Top 8 Ruby on Rails GemsTop 8 Ruby on Rails Gems
Top 8 Ruby on Rails Gems
 
JRuby, Ruby, Rails and You on the Cloud
JRuby, Ruby, Rails and You on the CloudJRuby, Ruby, Rails and You on the Cloud
JRuby, Ruby, Rails and You on the Cloud
 
Dynamic Languages & Web Frameworks in GlassFish
Dynamic Languages & Web Frameworks in GlassFishDynamic Languages & Web Frameworks in GlassFish
Dynamic Languages & Web Frameworks in GlassFish
 

Kürzlich hochgeladen

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Kürzlich hochgeladen (20)

%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 

React brief introduction

  • 3. It's the "V" in MVC
  • 5. Like... really fast Photo: Tim Shields, https://www.flickr.com/photos/glaciertim/4320524072/
  • 6. Virtual DOM Think of it like something similar to russian doll caching
  • 7. Advantages • Easy plug and play - even in existing, mature application • Can be rendered server-side • DOM manipulation in one place • Re-render only what needed
  • 8. –Yoda „So how to use it in Rails, you wondering must”
  • 9. 1 gem 'therubyracer' # it's just fast 2 # https://github.com/reactjs/react-rails/pull/290 3 gem 'react-rails', '~> 1.4.0' 1 # config/environments/development.rb 2 RewardsThem::Application.configure do 3 config.react.variant = :development 4 end 1. 2.
  • 10. 1 <div class="row"> 2 <div class="col-lg-7 col-md-12"> 3 <h3> 4 What happend recently 5 </h3> 6 <% @rewards.each do |reward| %> 7 <%= render reward %> 8 <% end %> 9 </div> 10 </div> 11 1 <div class="row"> 2 <div class="col-lg-7 col-md-12"> 3 <h3> 4 What happend recently 5 </h3> 6 <% @rewards.each do |reward| %> 7 <%= react_component 'Reward', reward: reward.to_json %> 8 <% end %> 9 </div> 10 </div> 11
  • 11. 1 class Reward extends React.Component{ 2 render(){ 3 const reward = this.props.reward; 4 return ( 5 <div className={ this.rewardClass() }> 6 <div className="created_at">{ reward.created_at }</div> 7 <div className="description"> 8 <a href={ reward.giver_path }>{ reward.giver }</a> 9 <div className="glyphicon glyphicon-arrow-right" /> 10 <a href={ reward.recipient_path }>{ reward.recipient }</a> 11 <div className="border"> 12 { reward.description } 13 <div className="points">{ reward.value }</div> 14 </div> 15 </div> 1 <div class="<%= reward_class(reward) %>"> 2 <div class="created_at"> 3 <%= reward.created_at.to_s(:short) %> 4 </div> 5 <div class="description"> 6 <%= link_to reward.giver, user_path(reward.giver) %> 7 <div class="glyphicon glyphicon-arrow-right"></div> 8 <%= link_to reward.recipient, user_path(reward.recipient) %> 9 <div class="border"> 10 <%= emojify reward.description %> 11 <div class="points"> 12 <%= reward.value_with_unit %> 13 </div> 14 </div> 15 </div> 16 </div>