Home > OS >  Error PropTypes React Native undefined is not an object (evaluating '_propTypes.default.nymber.
Error PropTypes React Native undefined is not an object (evaluating '_propTypes.default.nymber.

Time:09-18

I'm doing a weather project on React Native error with PropTypes The code:


import React from "react";
import PropTypes from 'prop-types';
import { StyleSheet, Text, View } from "react-native";

export default function Wather({temp}) {
 return (
   <View style={styles.container}>
     <Text>{temp}</Text>
   </View>
 );
}

Wather.propTypes = {
 temp:PropTypes.nymber.isRequired,
}

const styles = StyleSheet.create({
 container: {
   flex: 1,
   backgroundColor: "#FDF6AA",
   justifyContent: "flex-end",
   paddingHorizontal: 30,
   paddingVertical: 100,
 },
});

Erorr name: undefined is not an object (evaluating '_propTypes.default.nymber.isRequired')

CodePudding user response:

I think you have made a typo error. It should be PropTypes.number and not PropTypes.nymber

After fixing typo error it should look like this : Wather.propTypes = { temp:PropTypes.number.isRequired, }

  • Related