ReactTraining / react-history

Manage session history with React
266 stars 23 forks source link

Share as much code as possible between history providers #16

Closed ForbesLindesay closed 7 years ago

ForbesLindesay commented 7 years ago

I think this may be a better approach than #15. Rather than explicitly importing all the bits that are shared, just explicitly provide all the differences to a factory function. This leads to a really small amount of code duplication. I think it results in very explicit, clean code.

mjackson commented 7 years ago

Thanks for the PR, @ForbesLindesay :) I actually run through a similar exercise the other day when I first duplicated all that code. In the end, I decided to leave it as it was just because the main reason for reducing the duplication was for my benefit, not users. Users of this library should only ever import one implementation anyway, so there's no real reason for them to share as much code as possible. In the end, it just means they're running more code 😅