Example of Share Post URL from React Native App to Facebook

Hello guys, As we all know Facebook covers a large amount of our lives. Social Media helps us to connect with our loved once, friends and family with a very significant way. In today’s tutorial we would learn about something new. Today we would learn about sharing Text message and web address from our react native app to Facebook news feed, wall and Story. This can be possible via Linking component in react native. Now what we’re going to do is we would make 2 Text Input component and on the First Text Input user will enter any web address which he wants to share and on the next Text input he can enter any message. Now when user click on the Post button then it will automatically redirect to Facebook App(If installed in mobile) or open the Facebook in mobile default web browser. So in this tutorial we would learn about Example of Share Post URL from React Native App to Facebook.

Contents in this project Example of Share Post URL from React Native App to Facebook :-

1. Open your project’s main App.js file and import Alert, Linking, View, StyleSheet, SafeAreaView, Text, TouchableOpacity and TextInput component.

2. Creating our main component default App.

3. Creating a State named as fbShareURL with State update method setfbShareURL(). This state is used to hold the URL which we want to share on Facebook. Default value is our own website name.

4. Creating another state named as content with State update method setContent(). This state is used to  store the text post message which we want to share with our URL.

5. Creating a function named as publishOnFB(). In this function we would simply add our URL and message to a params variable and send it to FB using linking component.

6. Creating return() block, Now we would make 2 Text Input component and 1 Touchable opacity button.

7. Creating Style.

8. Complete Source Code for App.js file :-

Screenshots :-

Example of Share Post URL from React Native App to Facebook

Leave a Reply

Your email address will not be published.