0
I am creating a React application with the following flow:
Man App.js
imports the Components header, body and footer. The body.js
imports an event class called Play
.
However, in the declaration var evento = Play();
class Play is generating the error:
You know what might be going on?
(0, _play.defalt) is not a Function. (In '(0, play.defalt)()','(0, _play.defalt)' is Undefined)
body js.
var evento = Play();
export default class Body extends Component {
render() {
const [value, onChangeText] = React.useState('');
return (
<View>
<Text style={styles.text}>Type what you hear</Text>
<TouchableOpacity
title="Play"
onPress={evento.onPressButtonPlay.bind(this)}>
<Image
source={require('../resources/img/play.jpg')}
style={styles.play}
/>
</TouchableOpacity>
<TextInput
style={styles.textarea}
onChangeText={text => onChangeText(text)}
value={value}
/>
</View>
);
}
}
play js.
export class Play {
constructor() {
this.song = null;
}
onPressButtonPlay() {
this.song = new Sound('my_sound.mp3', Sound.MAIN_BUNDLE, error => {
if (error)
ToastAndroid.show(
'Error when init SoundPlayer :(((' + error.message,
ToastAndroid.SHORT,
);
else {
this.song.play(success => {
if (!success)
ToastAndroid.show(
'Error when play SoundPlayer :(((',
ToastAndroid.SHORT,
);
});
}
});
}
}