Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#01 - The Medium Clap #1

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

#01 - The Medium Clap #1

wants to merge 9 commits into from

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.

None yet

1 participant