ReactJS Mixins

17
The Public Parts Employer: Unicon, Inc Role: Sr. UI Developer Blog: blog.bradleygore.com Family: Carolina & Garrison About Me

Transcript of ReactJS Mixins

Page 1: ReactJS Mixins

The Public PartsEmployer: Unicon, IncRole: Sr. UI Developer

Blog: blog.bradleygore.comFamily: Carolina & Garrison

About Me

Page 2: ReactJS Mixins
Page 3: ReactJS Mixins

Mixin’ It UpWith React Mixins -Bradley Gore

Page 4: ReactJS Mixins

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.

Page 5: ReactJS Mixins

Solution: Form Component where Inputs are “Registered”

Submit

Snap-in Form

Text Input Field registerWithForm()

Number Input Field deRegisterFromForm()

Field Container

Page 6: ReactJS Mixins

What are React mixins?Mixins are a way for totally separate components to have common functionality...

Page 7: ReactJS Mixins

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.

Page 8: ReactJS Mixins
Page 9: ReactJS Mixins
Page 10: ReactJS Mixins
Page 11: 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.

Page 12: ReactJS Mixins

Pass props to child elements during render

Page 13: ReactJS Mixins

Pass props to child elements during render

Page 14: ReactJS Mixins

Pass props to child elements during render

Page 15: ReactJS Mixins

Simple Input Component

Page 16: ReactJS Mixins

Putting Together All The Things

Page 17: ReactJS Mixins

Thank You!

Slides: http://goo.gl/QI7p2aDemo: http://goo.gl/xD8yQ4

Email: [email protected]: @dotNetKnight