DEV Community

Discussion on: React useComponent pattern

Collapse
 
bendtherules profile image
Abhas Bhattacharya

Really nice pattern

But i think -

  1. In counter definition, use should have a default value of useCounter. That way none of the consumers need to explicitly pass it if they just want the default behavior.
  2. This example doesn't really show its benefits. We are not passing any customised logic to both instances of Counter. So, if this was a simple component, it would need no props and still do same thing. If we pass two different behaviours as props in two instances of counter, then only this patterns flexibility makes more sense