This is JSON DATA
{
"sad": [
{ "id": "1", "title": "hello this is no.1" },
{
"id": "2",
"title": "आँखें थक गई है आसमान को देखते देखते पर वो तारा नहीं टूटता ,जिसे देखकर तुम्हें मांग लूँ"
},
{
"id": "3",
"title": "मेरी हर आह को वाह मिली है यहाँ…..,कौन कहता है दर्द बिकता नहीं है !"
},
{
"id": "4",
"title": "तुझसे अच्छे तो जख्म हैं मेरे । उतनी ही तकलीफ देते हैं जितनी बर्दास्त कर सकूँ"
},
{
"id": "5",
"title": "रुठुंगा अगर तुजसे तो इस कदर रुठुंगा की ये तेरीे आँखे मेरी एक झलक को तरसेंगी !!"
},
{
"id": "6",
"title": "बेवफा लोग बढ़ रहे हैं धीरे धीरे, इक शहर अब इनका भी होना चाहिए"
},
{
"id": "7",
"title": "बेवफा लोग बढ़ रहे हैं धीरे धीरे, इक शहर अब इनका भी होना चाहिए"
},
{
"id": "8",
"title": "बेवफा लोग बढ़ रहे हैं धीरे धीरे, इक शहर अब इनका भी होना चाहिए"
},
{
"id": "9",
"title": "बेवफा लोग बढ़ रहे हैं धीरे धीरे, इक शहर अब इनका भी होना चाहिए"
}
]
}
And this is my code, I want to know what should I do for share this particular data when user press on share button
Here I imported all library
import React, { Component, useState, useEffect } from "react";
import {
StyleSheet,
View,
Text,
FlatList,
ListView,
TouchableOpacity,
Share,
} from "react-native";
import Icon from "react-native-vector-icons";
import SadJson from "./sad.json";
var d = SadJson.sad;
const sad = ({ navigation }) => {
const [data, setData] = useState([]);
// This is share method code
const onShare = async () => {
try {
const result = await Share.share({
message: data.toString(d),
});
} catch (error) {
alert(error.message);
}
};
useEffect(() => {
setData(d);
});
// This is return section where I use Flatlist for show Data
return (
<View style={styles.container}>
<FlatList
data={data}
removeClippedSubviews={false}
renderItem={({ item }) => (
<View>
<Text>
{item.id}
{item.title}
</Text>
<View style={{ flexDirection: "row" }}>
<TouchableOpacity style={styles.sharebtn} onPress={onShare}>
<Text>Share{item.id}</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.sharebtn}>
<Text>Copy</Text>
</TouchableOpacity>
</View>
</View>
)}
/>
</View>
);
};
// This is Style section
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: "center",
},
sharebtn: {
width: 60,
height: 30,
padding: 5,
backgroundColor: "#2BDB25",
borderRadius: 10,
},
btntext: {
textAlign: "center",
},
});
export default sad;
Please help me and Please let me know how to share this data on social media or any other App