Share URL via Webshare
Last week was a little different than what I am used to... I took notes at our previous meeting and forgot to get finished with providing the user a way to share their pet information when they are on the pet details page. I did some research on this but I ended up letting time go by and then I let other tasks take the majority of my attention. I nearly ended the week with nothing to show for the progress of the share mechanism. So, yesterday I got home and started working on the share functionality and found some articles that allow the user to share via Facebook after they click an icon.
Facebook share with reactjs - Stack Overflow.
Share Button - Social Plugins (facebook.com)
Then I found a way to make an email icon and allow the user to share a link via email by using their preferred email client. How to share current URL in ReactJS - Stack Overflow
I scrolled down some more and found something called react web share. This is a package that will allow the user to have more than one way to share and also provides a way for them to copy the URL and paste wherever they wish. I followed this guide and implemented it into the pet details page.
Installation and Setup : npm i react-web-share
How to activate web share using react-web-share in ReactJS ? - GeeksforGeeks
I now have a button that is clicked then it displays a menu for the user and give them a lot more options to choose from when they want to share the url to a social media.
In the pictured example, we have the browser after the web share button is clicked and to the right of the window, we have the email button clicked and the preferred client comes forth then, finally, the Facebook link is clicked and the browser opens a small window.
Note - Since we are looking for a hosting site, Facebook gives an error : Parameter 'href' should represent a valid URL because facebook does not allow local host url to be shared on facebook.
I like the web share button at this time but I do understand why the individual buttons would work as well. It's just a matter of time so we can find out what works best for our website.
Comments
Post a Comment