When i try to run the app after some changes i get this error. What i'm doing wrong ?
Module RCTEventEmitter is not a registered callable module (calling receiveTouches) __callFunction C:\Users\Andrea Zani\Documents\WORK\weatherApp\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:295:6 C:\Users\Andrea Zani\Documents\WORK\weatherApp\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:108:26 __guard C:\Users\Andrea Zani\Documents\WORK\weatherApp\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:269:6 callFunctionReturnFlushedQueue C:\Users\Andrea Zani\Documents\WORK\weatherApp\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:107:17
and here is the code
import React, { Component } from 'react-native'
import {
StyleSheet,
Text,
View,
TextInput,
TouchableHighlight,
Animated,
ScrollView,
} from 'react-native'
import fetchWeather from './app/api/api'
import weatherIcon from './app/utils/icons'
class WeatherAppNative extends React.Component {
getInitialState() {
return {
city: 'Bucuresti',
country: 'Romania',
weatherType: 'Clear',
temperature: 21,
searchedCity: 'Bucuresti',
val: new Animated.Value(0),
currentColor: 'rgba(255,255,255,0.5)',
nextColor: this._randomColor(),
icon: weatherIcon()
}
}
getWeather() {
fetchWeather(this.state.searchedCity).then((response) => {
let weatherList = response.list[0]
// Store nextColor, since we'd like to start next time with it.
var current = this.state.nextColor
// Reset animation
this.state.val.setValue(0)
this.setState({
temperature: weatherList.main.temp,
city: weatherList.name,
country: weatherList.sys.country,
weatherType: weatherList.weather[0].main,
currentColor: current,
nextColor: this._randomColor(),
icon: weatherIcon(weatherList.weather[0].icon)
})
})
}
render() {
var backgroundColor = this.state.val.interpolate({
inputRange: [0, 1],
outputRange: [
this.state.currentColor,
this.state.nextColor
],
})
// Start the animation
Animated.spring(this.state.val, {
tension: 1,
friction: 20,
toValue: 1
}).start()
return (
<Animated.View style={{
backgroundColor: backgroundColor,
flex: 1,
alignItems: 'stretch',
justifyContent: 'center'}}>
<View style={{marginBottom: this.state.keyboardSpace}}>
<View style={[styles.animatedContainer]}>
<Text style={styles.icon}>
{this.state.icon}
</Text>
<Text style={styles.temperature}>
{Math.round(this.state.temperature) + '°C'}
</Text>
<Text style={styles.location}>
{this.state.city}, {this.state.country}
</Text>
<Text style={styles.weatherType}>
{this.state.weatherType}
</Text>
<TextInput style={styles.input}
onChangeText={this.onChangeText}
onSubmitEditing={this.getWeather}
clearButtonMode={'always'}
clearTextOnFocus={true}
enablesReturnKeyAutomatically={true}
returnKeyType={'search'}/>
</View>
</View>
</Animated.View>
)
}
onChangeText(searchedCity) {
this.setState({
searchedCity: searchedCity
})
}
_randomColor() {
var colors = [0, 1, 2].map(() => Math.ceil(Math.random() * 255))
return 'rgba(' + colors.join(',') + ',0.6)'
}
}
var styles = StyleSheet.create({
animatedContainer: {
alignItems: 'center',
justifyContent: 'center'
},
temperature: {
fontSize: 62,
fontWeight: '100',
margin: 0
},
location: {
fontSize: 14,
fontWeight: '100',
marginBottom: 20,
},
weatherType: {
fontSize: 34,
fontWeight: '500'
},
input: {
borderWidth: 1,
borderColor: '#666',
height: 40,
marginVertical: 20,
marginHorizontal: 20,
paddingHorizontal: 10,
borderRadius: 5
},
icon: {
fontFamily: 'WeatherIcons-Regular',
fontSize: 130,
padding: 0
}
})
export default WeatherAppNative
you will have to kill the node process pkill node
and re-run the build react-native run-android
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With