Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Using Facade pattern with JSX

Using Facade pattern with JSX

Even though the JSX resemble HTML at the first glance it is only the description of the expected UI and is not the UI by itself. What if we can use this fact and play a little with the JSX tags to make the HOC that will allow us to create similar repetitive components in our apps? I will present a small pattern that I found quite useful in one project for creating different users list.

Olena Sovyn

June 20, 2017
Tweet

More Decks by Olena Sovyn

Other Decks in Programming

Transcript

  1. Using Facade pattern
    with JSX
    Olena Sovyn

    (@frontendgirl)

    View Slide

  2. Avatar Name
    Email
    Phone EditUser

    View Slide

  3. View Slide

  4. components.jsx

    View Slide

  5. App.js

    View Slide

  6. user-list.jsx

    View Slide

  7. user-list.jsx

    View Slide

  8. View Slide

  9. App.js

    View Slide

  10. App.js

    View Slide

  11. Facade pattern
    Source: https://www.sitepoint.com/manage-complexity-with-the-facade-pattern/

    View Slide

  12. user-list.jsx

    View Slide

  13. View Slide

  14. extendable textarea react component:

    https://github.com/andreypopp/react-textarea-autosize

    View Slide

  15. Compound Components
    … or the

    View Slide

  16. user-list.jsx

    View Slide

  17. View Slide

  18. 100% correct solution

    View Slide

  19. Why?
    • Business requirements are different between the projects

    • Size of the project are different

    • Our React ecosystem can be different between the
    projects

    • We do not know the future

    View Slide

  20. JSX

    View Slide

  21. JSX

    View Slide