import { Appear } from 'mdx-deck' export { default as theme } from './theme'
Software Engineer
- Javascript: React, State Managements, Node.js
- Open Source (🙏 Github)
- FP: Elm, Reason
- Twitter: @Farzad_YZ
- Medium : @Farzad_YZ
- Github : @farskid
- Website: farzadyz.com
class MyComponent extends React.Component {
render() {
// Render here
}
}
render
: the only required method
- Delrataive renderings
- Not a framework but a rendering library
- Thinking in React === Thinking about different rendering sections
- Render based on props vs Render based on props and state
- Statefull vs Stateless, Container vs Component, Dumb vs Smart
What if I told you, React is
NOT ONLY FOR RENDERING
?
Headless ~ Renderless
No Rendering === No GUI
- Render nothing!
return null
- Delegate rendering (Render Props)
this.props.children(...args)
- Decorating (HOC)
withRouter
connect
© Merrick Christensen
Bring back Tails and Heads text for SEO
- Support 2 usecases with different implementations
- Add a button to flip again on click
Your coworker comes by and wants to re-use your CoinFlip component for new usecase <DiceRoll />
- Totally different interface
- Also be used in both app and blog
- Totally different odd! (diceroll in 1/6 but coinflip is 1/2)
- Sorry, go dice yourself.
- Add DiceRoll to CoinFlip too!
(🔉 Crushing barebones sound in the background)
Let's decouple the logic from rendering.
- Probability, 1st abstraction, Headless (different odds)
- CoinFlip and DiceRolle, 2nd abstraction, Still Headless (different implementations)
- BlogCoinFlip, AppCoinFlip, BlogDiceRoll, AppDiceRoll
- Separation of concerns
- Easier to reason about
- Easier to test
- Decoupling === (maintainable, small learning curve)
- Reusable, Composable
- Scalable for change of requirements
- Same as other abstractions
- Implementation cost (time, code size)
- Cost of indirection
- Codebase learning curve
Like any other abstractions, when the benefits weigh more than the costs.
- Declarative Side effects (fetch, logging, timers, Web Speech, Geolocation, WebRTC handlers, ...)
- Separating Logics (Abstract logics, State moderation)
- Declatarive data structures (Map, set, WeakMap, List)
- Declarative feedbacks (Hover, Focus, Active)
- Declarative Form Data (!!)
- Declarative State reducers, state selectors (Redux in React 😱)
Slides Available at: