Kikobeats / react-clap-button

A Medium like clap button
https://react-clap-button.netlify.com
120 stars 17 forks source link

Dev switch option #47

Open tianzhich opened 4 years ago

tianzhich commented 4 years ago
  1. Mark babel-loader as dependency for non-babel users.
  2. Use babel-loader@7.1.5 to avoid some errors.
  3. Add canSwitch option.

closes #46

Kikobeats commented 4 years ago

why babel-loader as dependency is necessary? 🤔

tianzhich commented 4 years ago

According to storybookjs/storybook#4116, babel-loader is peerDependencies of @storybook/react. So project using storybook should mark it as dependency.😁

Kikobeats commented 4 years ago

What do you think about to take this an opportunity to expose an inversion of control? https://kentcdodds.com/blog/inversion-of-control

Thinking this is a very specific case and we are just adding much code there

tianzhich commented 4 years ago

Do you have any ideas here?

Cause react-clap-button is not a fully-controlled component, the count and countTotal change depends on internal state. I think it could be fully controlled if we passed the count, or countTotalsimilarly. And the count could be defaultCount accordingly. So increase shows +1 and decrease shows -1.

Then users can implement switch effect if they want.