68
Olena Sovyn (@frontendgirl) Webflow Understanding Recompose through examples

Olena Sovyn "Understanding Recompose through examples"

  • Upload
    fwdays

  • View
    98

  • Download
    6

Embed Size (px)

Citation preview

Page 1: Olena Sovyn "Understanding Recompose through examples"

Olena Sovyn (@frontendgirl)Webflow

Understanding Recompose through examples

Page 2: Olena Sovyn "Understanding Recompose through examples"

Olena Sovyn (@frontendgirl)

! & !

Page 3: Olena Sovyn "Understanding Recompose through examples"

ReactRedux Lodash React Storybook functional programming

Page 4: Olena Sovyn "Understanding Recompose through examples"
Page 5: Olena Sovyn "Understanding Recompose through examples"

Olena Sovyn (@frontendgirl)

Understanding Recompose through

examples

Page 6: Olena Sovyn "Understanding Recompose through examples"

Image source: https://szenandoah.deviantart.com/art/Wonderland-Logo-252210579

Page 7: Olena Sovyn "Understanding Recompose through examples"

1 year ago . . .

Page 8: Olena Sovyn "Understanding Recompose through examples"

How to make complex

component to be reusable?

Page 9: Olena Sovyn "Understanding Recompose through examples"

Data

Behaviour

UI

Reusable ???

Page 10: Olena Sovyn "Understanding Recompose through examples"

HOC (high order components)

Page 11: Olena Sovyn "Understanding Recompose through examples"

HOC

changed: context or/and props

Page 12: Olena Sovyn "Understanding Recompose through examples"

Recompose

Page 13: Olena Sovyn "Understanding Recompose through examples"

Data

Behaviour

UI

Recompose HOC

Stateless component

Page 14: Olena Sovyn "Understanding Recompose through examples"
Page 15: Olena Sovyn "Understanding Recompose through examples"

Why should I care about Recompose?

Page 16: Olena Sovyn "Understanding Recompose through examples"

Image source: http://spacenews.com/spacexs-new-price-chart-illustrates-performance-cost-of-reusability/

Page 17: Olena Sovyn "Understanding Recompose through examples"
Page 18: Olena Sovyn "Understanding Recompose through examples"

Image source: https://whataboutjesus.com/jesus-is-the-only-way/

Page 19: Olena Sovyn "Understanding Recompose through examples"

setDisplayNametoClass

lifecycle

getContext

withContextonlyUpdateForPropTypes

onlyUpdateForKeys

setStatic

setPropTypes

componentFromStream

setObservableConfig

createEventHandlerWithConfig

createEventHandler

mapPropsStreamWithConfig

mapPropsStream

componentFromStreamWithConfig

compose

isClassComponent

getDisplayName

wrapDisplayNameshallowEqual

createSink

componentFromProp

nest

hoistStatics

mapProps

withProps

withHandlers

withPropsOnChange

renameProps

defaultProps

renameProp

withState

renderComponent

renderNothing

withReducer

withStateHandlersshouldUpdatepure

branch

flattenProp

Page 20: Olena Sovyn "Understanding Recompose through examples"

setDisplayNametoClass

lifecycle

getContext

withContextonlyUpdateForPropTypes

onlyUpdateForKeys

setStatic

setPropTypes

componentFromStream

setObservableConfig

createEventHandlerWithConfig

createEventHandler

mapPropsStreamWithConfig

mapPropsStream

componentFromStreamWithConfig

compose

isClassComponent

getDisplayName

wrapDisplayNameshallowEqual

createSink

componentFromProp

nest

hoistStatics

mapProps

withProps

withHandlers

withPropsOnChange

renameProps

defaultProps

renameProp

withState

renderComponent

renderNothing

withReducer

withStateHandlersshouldUpdatepure

branch

flattenProp

Page 21: Olena Sovyn "Understanding Recompose through examples"

setDisplayNametoClass

lifecycle

getContext

withContextonlyUpdateForPropTypes

onlyUpdateForKeys

setStatic

setPropTypes

componentFromStream

setObservableConfig

createEventHandlerWithConfig

createEventHandler

mapPropsStreamWithConfig

mapPropsStream

componentFromStreamWithConfig

compose

isClassComponent

getDisplayName

wrapDisplayNameshallowEqual

createSink

componentFromProp

nest

hoistStatics

mapProps

withProps

withHandlers

withPropsOnChange

renameProps

defaultProps

renameProp

withState

renderComponent

renderNothing

withReducer

withStateHandlersshouldUpdatepure

branch

flattenProp

Page 22: Olena Sovyn "Understanding Recompose through examples"

setDisplayNametoClass

lifecycle

getContext

withContextonlyUpdateForPropTypes

onlyUpdateForKeys

setStatic

setPropTypes

componentFromStream

setObservableConfig

createEventHandlerWithConfig

createEventHandler

mapPropsStreamWithConfig

mapPropsStream

componentFromStreamWithConfig

compose

isClassComponent

getDisplayName

wrapDisplayNameshallowEqual

createSink

componentFromProp

nest

hoistStatics

mapProps

withProps

withHandlers

withPropsOnChange

renameProps

defaultProps

renameProp

withState

renderComponent

renderNothing

withReducer

withStateHandlersshouldUpdatepure

branch

flattenProp

Page 23: Olena Sovyn "Understanding Recompose through examples"

setDisplayNametoClass

lifecycle

getContext

withContextonlyUpdateForPropTypes

onlyUpdateForKeys

setStatic

setPropTypes

componentFromStream

setObservableConfig

createEventHandlerWithConfig

createEventHandler

mapPropsStreamWithConfig

mapPropsStream

componentFromStreamWithConfig

compose

isClassComponent

getDisplayName

wrapDisplayNameshallowEqual

createSink

componentFromProp

nest

hoistStatics

mapProps

withProps

withHandlers

withPropsOnChange

renameProps

defaultProps

renameProp

withState

renderComponent

renderNothing

withReducer

withStateHandlersshouldUpdatepure

branch

flattenProp

Page 24: Olena Sovyn "Understanding Recompose through examples"

setDisplayNametoClass

lifecycle

getContext

withContextonlyUpdateForPropTypes

onlyUpdateForKeys

setStatic

setPropTypes

componentFromStream

setObservableConfig

createEventHandlerWithConfig

createEventHandler

mapPropsStreamWithConfig

mapPropsStream

componentFromStreamWithConfig

compose

isClassComponent

getDisplayName

wrapDisplayNameshallowEqual

createSink

componentFromProp

nest

hoistStatics

mapProps

withProps

withHandlers

withPropsOnChange

renameProps

defaultProps

renameProp

withState

renderComponent

renderNothing

withReducer

withStateHandlersshouldUpdatepure

branch

flattenProp

Page 25: Olena Sovyn "Understanding Recompose through examples"

Dunning‒Kruger effectCo

nfide

nce

Wisdom

first usage of one of Recompose

HOCs

reading Recompose

documentation

trying to use Recompose on

practice

Page 26: Olena Sovyn "Understanding Recompose through examples"
Page 27: Olena Sovyn "Understanding Recompose through examples"

setDisplayNametoClass

lifecycle

getContext

withContextonlyUpdateForPropTypes

onlyUpdateForKeys

setStatic

setPropTypes

componentFromStream

setObservableConfig

createEventHandlerWithConfig

createEventHandler

mapPropsStreamWithConfig

mapPropsStream

componentFromStreamWithConfig

compose

isClassComponent

getDisplayName

wrapDisplayNameshallowEqual

createSink

componentFromProp

nest

hoistStatics

mapProps

withProps

withHandlers

withPropsOnChange

renameProps

defaultProps

renameProp

withState

renderComponent

renderNothing

withReducer

withStateHandlersshouldUpdatepure

branch

flattenProp

Page 28: Olena Sovyn "Understanding Recompose through examples"
Page 29: Olena Sovyn "Understanding Recompose through examples"
Page 30: Olena Sovyn "Understanding Recompose through examples"
Page 31: Olena Sovyn "Understanding Recompose through examples"

branch lifecycle renderComponent renderNothing toClass

mapProps withProps withPropsOnChange defaultProps renameProp renameProps flattenProp

withState withHandlers withStateHandlers withReducer

shouldUpdate pure onlyUpdateForKeys onlyUpdateForPropTypes

withContext getContext

Props

State Performance

Other

Context

RecomposeHOCs

Page 32: Olena Sovyn "Understanding Recompose through examples"

branch lifecycle renderComponent renderNothing toClass

mapProps withProps withPropsOnChange defaultProps renameProp renameProps flattenProp

withState withHandlers withStateHandlers withReducer

shouldUpdate pure onlyUpdateForKeys onlyUpdateForPropTypes

withContext getContext

Props

State Performance

Other

Context

RecomposeHOCs

Page 33: Olena Sovyn "Understanding Recompose through examples"
Page 34: Olena Sovyn "Understanding Recompose through examples"
Page 35: Olena Sovyn "Understanding Recompose through examples"
Page 36: Olena Sovyn "Understanding Recompose through examples"
Page 37: Olena Sovyn "Understanding Recompose through examples"
Page 38: Olena Sovyn "Understanding Recompose through examples"
Page 39: Olena Sovyn "Understanding Recompose through examples"
Page 40: Olena Sovyn "Understanding Recompose through examples"

< 280

Page 41: Olena Sovyn "Understanding Recompose through examples"

Reusability

Page 42: Olena Sovyn "Understanding Recompose through examples"

lifecycle

Image source: https://www.codevoila.com/post/57/reactjs-tutorial-react-component-lifecycle

Page 43: Olena Sovyn "Understanding Recompose through examples"
Page 44: Olena Sovyn "Understanding Recompose through examples"
Page 45: Olena Sovyn "Understanding Recompose through examples"
Page 46: Olena Sovyn "Understanding Recompose through examples"
Page 47: Olena Sovyn "Understanding Recompose through examples"
Page 48: Olena Sovyn "Understanding Recompose through examples"
Page 49: Olena Sovyn "Understanding Recompose through examples"
Page 50: Olena Sovyn "Understanding Recompose through examples"

timeExamples

Page 51: Olena Sovyn "Understanding Recompose through examples"
Page 52: Olena Sovyn "Understanding Recompose through examples"

setDisplayNametoClass

lifecycle

getContext

withContextonlyUpdateForPropTypes

onlyUpdateForKeys

setStatic

setPropTypes

componentFromStream

setObservableConfig

createEventHandlerWithConfig

createEventHandler

mapPropsStreamWithConfig

mapPropsStream

componentFromStreamWithConfig

compose

isClassComponent

getDisplayName

wrapDisplayNameshallowEqual

createSink

componentFromProp

nest

hoistStatics

mapProps

withProps

withHandlers

withPropsOnChange

renameProps

defaultProps

renameProp

withState

renderComponent

renderNothing

withReducer

withStateHandlersshouldUpdatepure

branch

flattenProp

Page 53: Olena Sovyn "Understanding Recompose through examples"

Any takeaways?

Page 54: Olena Sovyn "Understanding Recompose through examples"

Even if you are not directly contributing to libraries you have still a lot to share3

Page 55: Olena Sovyn "Understanding Recompose through examples"

Awesome Recompose

Page 56: Olena Sovyn "Understanding Recompose through examples"

Make ideas clearly stand out in your examples, no matter how complex they are2

Page 57: Olena Sovyn "Understanding Recompose through examples"

Useful Example

Complex example

Simple example

Page 58: Olena Sovyn "Understanding Recompose through examples"

Even if something wasn’t clear from the first time there is always another way1

Page 59: Olena Sovyn "Understanding Recompose through examples"

Django Girls Kyiv #1

Page 60: Olena Sovyn "Understanding Recompose through examples"
Page 61: Olena Sovyn "Understanding Recompose through examples"

Image source: https://hacks.mozilla.org/2017/11/entering-the-quantum-era-how-firefox-got-fast-again-and-where-its-going-to-get-faster/

Lin Clark works

Page 62: Olena Sovyn "Understanding Recompose through examples"

Image source: https://twitter.com/kosamari/status/859958929484337152

Codedoodles by Mariko Kosaka

Page 63: Olena Sovyn "Understanding Recompose through examples"
Page 64: Olena Sovyn "Understanding Recompose through examples"

Code Example

Input Output

Page 65: Olena Sovyn "Understanding Recompose through examples"
Page 66: Olena Sovyn "Understanding Recompose through examples"
Page 67: Olena Sovyn "Understanding Recompose through examples"

Even if something wasn’t clear from the first time there is always another way1

Page 68: Olena Sovyn "Understanding Recompose through examples"