0
이 자습서를 따라이 오류를 발견했습니다. 내가 잘못하고 있는지 또는 코드에 오류가 있는지 확실하지 않습니다.네이티브 Share.share가 텍스트 공유를 위해 작동하지 않음
Share.share가 작동하지 않습니다. 이 기능과 관련하여 온라인에서 아무 것도 찾을 수 없습니다.
오류 메시지
Share.js
당신은뿐만 아니라 공유 클래스를 가져와야import React, { Component } from 'react'
import { View, Text, StyleSheet, Image, TouchableHighlight } from 'react-native'
class Share extends Component {
constructor(props){
super(props);
this._shareMessage = this._shareMessage.bind(this);
this._showResult = this._showResult.bind(this);
this.state = {result: 'Hello'};
}
_showResult(result){
this.setState({result})
}
_shareMessage() {
Share.share({
message: 'This is a fancy shared message'
}).then(this._showResult);
}
render(){
return (
<View style={styles.container}>
<TouchableHighlight onPress = {this._shareMessage}>
<Text style={styles.text}>Share</Text>
</TouchableHighlight>
<Text>
{JSON.stringify(this.state.result)}
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#10a2f0',
alignItems: 'center'
},
text: {
color: 'rgb(0,10,200)',
marginTop: 100,
fontSize: 24,
textAlign: 'center'
},
image: {
width: 250,
height: 250
}
})
export default Share