nygardk / react-share

Social media share buttons and share counts for React
MIT License
2.63k stars 433 forks source link

Fix behavior when hatena share count is 0. #429

Closed tagucch closed 10 months ago

tagucch commented 2 years ago

Hello. Thank you for creating a great package! I found a bug in the hatena share count and send a pull requset for a fix. When share count is 0, It will behave like this.

// data is 0, will be interpreted as false and set undefined.
callback(data ? data : undefined)

So, if hatena share count is 0, it will just return an empty span element.

スクリーンショット 2022-01-17 2 31 02

To improve this, I have changed to use nullish coalescing operator. This way, 0 will be displayed correctly when share count is 0.

I apologize if this is hard to read as it may be in poor English. I'd love it if you could incorporate this request!