SlideShare a Scribd company logo
The Public Parts
Employer: Unicon, Inc
Role: Sr. UI Developer
Blog: blog.bradleygore.com
Family: Carolina & Garrison
About Me
ReactJS Mixins
Mixin’ It Up
With React Mixins -Bradley Gore
The Problem
HELP!
I have potential for dynamically
added/removed form-fields, but need for
my form component to know whether or
not it can submit.
PS: Also must work in all browsers, be beautiful, easy to use, and done ASAP.
Solution: Form Component where Inputs are “Registered”
Submit
Snap-in Form
Text Input Field registerWithForm()
Number Input Field deRegisterFromForm()
Field Container
What are React mixins?
Mixins are a way for totally separate
components to have common
functionality...
What are React mixins?
Mixins are a way for totally separate
components to have common
functionality...
...and still remain totally separated
even after the mixing is done.
ReactJS Mixins
ReactJS Mixins
ReactJS Mixins
Form Component
● inputs
○ empty object placeholder for registered inputs to live
● registerInput(input)
○ takes the input being registered. Inputs are expected to
have a name, as that’s the key in the inputs hash.
● deRegisterInput(name)
○ takes the de-registered input’s name, and deletes that key
from this.inputs
● updateValidity()
○ sets the form’s valid state based on all registered inputs -
fires any time a field is (de)registered.
Pass props to child elements during render
Pass props to child elements during render
Pass props to child elements during render
Simple Input Component
Putting Together All The Things
Thank You!
Slides: http://goo.gl/QI7p2a
Demo: http://goo.gl/xD8yQ4
Email: bradleyd60@gmail.com
Twitter: @dotNetKnight

More Related Content

PDF
Oracle SQL Interview Questions for Freshers
PDF
THE SEMIOTIC STATUS OF MOVIE TRAILERS
PDF
Management Consulting
PPTX
ReactJs
PDF
Clojure
PDF
ReactJS | 서버와 클라이어트에서 동시에 사용하는
PDF
Simo Ahava - Tag Management Solutions – Best. Data. Ever. MKTFEST 2014
Oracle SQL Interview Questions for Freshers
THE SEMIOTIC STATUS OF MOVIE TRAILERS
Management Consulting
ReactJs
Clojure
ReactJS | 서버와 클라이어트에서 동시에 사용하는
Simo Ahava - Tag Management Solutions – Best. Data. Ever. MKTFEST 2014

Viewers also liked (17)

PPT
Lionel Messi
PPT
Lionel messi
PDF
Personal Development
PDF
Growth Hacking
PPTX
The Big Bang Theory
PPTX
NHS presentation
PDF
Digital analytics: Optimization (Lecture 10)
PPT
KeyNote Connecting Up Conference
PPTX
The dodo birds
PPT
Louis Armstrong
 
PPTX
Building Great Digital Marketing Teams
PDF
Why Scala?
PPS
Bob Dylan: Voice of a generation
PDF
Digital Data Tips Tuesday #1 - Tag Management: Simo Ahava - NetBooster
PDF
Google's Avinash Kaushik on Web Analytics
PPTX
A Brief Intro to Scala
PPTX
Manchester city
Lionel Messi
Lionel messi
Personal Development
Growth Hacking
The Big Bang Theory
NHS presentation
Digital analytics: Optimization (Lecture 10)
KeyNote Connecting Up Conference
The dodo birds
Louis Armstrong
 
Building Great Digital Marketing Teams
Why Scala?
Bob Dylan: Voice of a generation
Digital Data Tips Tuesday #1 - Tag Management: Simo Ahava - NetBooster
Google's Avinash Kaushik on Web Analytics
A Brief Intro to Scala
Manchester city
Ad

Similar to ReactJS Mixins (20)

PPTX
Vb6.0 intro
DOCX
Cis 407 i lab 6 of 7
PPTX
#42 green lantern framework
PPTX
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
PDF
Page Objects Done Right - selenium conference 2014
PPT
DS Unit 6.ppt
PPS
Vb net xp_13
PDF
The Functional Programming Toolkit (NDC Oslo 2019)
PPT
Vb introduction.
PPTX
Custom fields in joomla
PDF
Advanced Dagger talk from 360andev
PDF
MobX: the way to simplicity
PDF
Evolving a Clean, Pragmatic Architecture - A Craftsman's Guide
PPTX
Bringing classical OOP into JavaScript
PPTX
object oriented programming language.pptx
PDF
Boo Manifesto
DOC
Cis407 a ilab 6 web application development devry university
PPTX
Intro To C++ - Class #19: Functions
PDF
Flash develop presentation
PPT
Engage - Expanding XPages with Bootstrap Plugins for ultimate usability
Vb6.0 intro
Cis 407 i lab 6 of 7
#42 green lantern framework
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
Page Objects Done Right - selenium conference 2014
DS Unit 6.ppt
Vb net xp_13
The Functional Programming Toolkit (NDC Oslo 2019)
Vb introduction.
Custom fields in joomla
Advanced Dagger talk from 360andev
MobX: the way to simplicity
Evolving a Clean, Pragmatic Architecture - A Craftsman's Guide
Bringing classical OOP into JavaScript
object oriented programming language.pptx
Boo Manifesto
Cis407 a ilab 6 web application development devry university
Intro To C++ - Class #19: Functions
Flash develop presentation
Engage - Expanding XPages with Bootstrap Plugins for ultimate usability
Ad

Recently uploaded (20)

PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Introduction to Artificial Intelligence
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
ISO 45001 Occupational Health and Safety Management System
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
medical staffing services at VALiNTRY
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Transform Your Business with a Software ERP System
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Online Work Permit System for Fast Permit Processing
PPTX
CHAPTER 2 - PM Management and IT Context
ManageIQ - Sprint 268 Review - Slide Deck
Softaken Excel to vCard Converter Software.pdf
Operating system designcfffgfgggggggvggggggggg
Introduction to Artificial Intelligence
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
ISO 45001 Occupational Health and Safety Management System
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Design an Analysis of Algorithms I-SECS-1021-03
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
medical staffing services at VALiNTRY
Which alternative to Crystal Reports is best for small or large businesses.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Transform Your Business with a Software ERP System
How to Choose the Right IT Partner for Your Business in Malaysia
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Wondershare Filmora 15 Crack With Activation Key [2025
Upgrade and Innovation Strategies for SAP ERP Customers
Online Work Permit System for Fast Permit Processing
CHAPTER 2 - PM Management and IT Context

ReactJS Mixins

  • 1. The Public Parts Employer: Unicon, Inc Role: Sr. UI Developer Blog: blog.bradleygore.com Family: Carolina & Garrison About Me
  • 3. Mixin’ It Up With React Mixins -Bradley Gore
  • 4. The Problem HELP! I have potential for dynamically added/removed form-fields, but need for my form component to know whether or not it can submit. PS: Also must work in all browsers, be beautiful, easy to use, and done ASAP.
  • 5. Solution: Form Component where Inputs are “Registered” Submit Snap-in Form Text Input Field registerWithForm() Number Input Field deRegisterFromForm() Field Container
  • 6. What are React mixins? Mixins are a way for totally separate components to have common functionality...
  • 7. What are React mixins? Mixins are a way for totally separate components to have common functionality... ...and still remain totally separated even after the mixing is done.
  • 11. Form Component ● inputs ○ empty object placeholder for registered inputs to live ● registerInput(input) ○ takes the input being registered. Inputs are expected to have a name, as that’s the key in the inputs hash. ● deRegisterInput(name) ○ takes the de-registered input’s name, and deletes that key from this.inputs ● updateValidity() ○ sets the form’s valid state based on all registered inputs - fires any time a field is (de)registered.
  • 12. Pass props to child elements during render
  • 13. Pass props to child elements during render
  • 14. Pass props to child elements during render
  • 16. Putting Together All The Things
  • 17. Thank You! Slides: http://goo.gl/QI7p2a Demo: http://goo.gl/xD8yQ4 Email: bradleyd60@gmail.com Twitter: @dotNetKnight

Editor's Notes

  • #2: Even if I bomb out here tonight, I’ll still be loved - my son’s shirt says so.
  • #6: We want our various input fields to be able to all implement the same common interface in order to keep the form container updated on what’s going on, but we don’t want to have to repeat our code for each one. This is where mixins come into play!
  • #8: Only the truly common functionality is shared. This is much cleaner than just extending one object by another because you need 3% of the source object’s functionality!
  • #9: Mixin is just a plain ole javascript object. Within methods, “this” is automatically scoped to the component instance by React. These should be lean - only purely common functionality should go here.
  • #10: Mixin is just a plain ole javascript object. Within methods, “this” is automatically scoped to the component instance by React. These should be lean - only purely common functionality should go here.
  • #11: Mixin is just a plain ole javascript object. Within methods, “this” is automatically scoped to the component instance by React. These should be lean - only purely common functionality should go here.
  • #12: updateValidity - any time a new component is (de)registered, the form needs to re-evaluate its own validity
  • #13: render - React lifecycle event
  • #14: clonedChildren is essentially the input container - all inputs render here, but the form itself controls the submit button. Could easily add in some props and some logic to allow any consumer of the form component to control the submit button label, if there’s a cancel button, its label, etc….
  • #15: clonedChildren is essentially the input container - all inputs render here, but the form itself controls the submit button. Could easily add in some props and some logic to allow any consumer of the form component to control the submit button label, if there’s a cancel button, its label, etc….
  • #16: This is what will use our mixin. We have to build a component around a standard text input in order to make it part of our React-based environment. The beautiful thing is that we can see at one glance all of the separate items that “mix in” to this class. No guessing, no hunting for an $.extend call that references an instance of this class - it’s clearly defined in one place. 2 more lifecycle events.