Skip to content

Conversation

ohansemmanuel
Copy link
Owner

@ohansemmanuel ohansemmanuel commented Oct 24, 2019

What is this PR about? 🤔

The initial implementation of the Medium clap via a class component

Changes 🎁

  • Utilize a Higher-Order Component, withClapAnimation
  • Use mo.js for animations

Before/After 📸

https://advanced-react-patterns-ultrasimplified.netlify.com/the-medium-clap

Other Comments 💬

Next PR: Refactor to Hooks

// 👉 prop from HOC
animationTimeline.replay()

setClapState({
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 IMPROVEMENT:
Relying on the previous state when invoking the updater function returned from useState? It's better to pass a function to the updater e.g.

setClapState(prevState => ({
      count: Math.min(prevState.count + 1, MAXIMUM_USER_CLAP),
      countTotal: prevState.count < MAXIMUM_USER_CLAP ? prevState.countTotal + 1 : prevState.countTotal,
      isClicked: true
}))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant