question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

propTypes is not defined

See original GitHub issue

i want use proptypes in my react native- redux projects . but i got the error "propTypes is not defined.

in this code:

import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';



class AntiHack extends React.Component {
  render() {
    return <div>{this.props.steps}</div>;
  }
}

AntiHack.PropTypes = {

    steps: propTypes.number.isRequired,
    
  }



  export default AntiHack

function degreesToRadians(degrees) {
    return degrees * Math.PI / 180;
  }

  
  function distanceInKmBetweenEarthCoordinates(lat1, lon1, lat2, lon2) {
    var earthRadiusKm = 6371;
  
    var dLat = degreesToRadians(lat2-lat1);
    var dLon = degreesToRadians(lon2-lon1);
  
    lat1 = degreesToRadians(lat1);
    lat2 = degreesToRadians(lat2);
  
    var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
            Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2); 
    var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
    return earthRadiusKm * c;
  }

console: and package.json:

{
“name”: “sirin”,
“version”: “0.1.0”,
“private”: true,
“devDependencies”: {
“jest-expo”: “~20.0.0”,
“react-native-scripts”: “1.2.1”,
“react-test-renderer”: “16.0.0-alpha.12”
},
“main”: “./node_modules/react-native-scripts/build/bin/crna-entry.js”,
“scripts”: {
“start”: “react-native-scripts start”,
“eject”: “react-native-scripts eject”,
“android”: “react-native-scripts android”,
“ios”: “react-native-scripts ios”,
“test”: “node node_modules/jest/bin/jest.js --watch”
},
“jest”: {
“preset”: “jest-expo”
},
“dependencies”: {
“art”: “^0.10.1”,
“d3”: “^4.10.2”,
“d3-array”: “^1.2.1”,
“d3-path”: “^1.0.5”,
“d3-shape”: “^1.2.0”,
“expo”: “^20.1.3”,
“prop-types”: “^15.5.10”,
“react”: “16.0.0-alpha.12”,
“react-native”: “^0.47.0”,
“react-native-chart”: “^1.0.8-beta”,
“react-native-charts-wrapper”: “^0.2.10”,
“react-native-circular-progress”: “^0.0.8”,
“react-native-customisable-switch”: “^0.1.0”,
“react-native-datepicker”: “^1.6.0”,
“react-native-device-info”: “^0.11.0”,
“react-native-drawer”: “^2.5.0”,
“react-native-elements”: “^0.16.0”,
“react-native-filesystem”: “^0.1.0”,
“react-native-installed-apps”: “0.0.6”,
“react-native-keyboard-aware-scroll-view”: “^0.3.0”,
“react-native-modal”: “^3.1.0”,
“react-native-pathjs-charts”: “0.0.31”,
“react-native-progress”: “^3.4.0”,
“react-native-responsive-image”: “^2.1.0”,
“react-native-shadow”: “^1.2.1”,
“react-native-side-menu”: “^1.0.2”,
“react-native-snap-carousel”: “^3.2.2”,
“react-native-svg”: “^5.4.1”,
“react-native-svg-image”: “^2.0.0”,
“react-native-svg-uri”: “^1.2.1”,
“react-native-switch”: “^1.1.0”,
“react-native-vector-icons”: “^4.3.0”,
“react-navigation”: “^1.0.0-beta.11”
}
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Ajith-Pandiancommented, Oct 12, 2017

@milad1367 You need to use “PropTypes” not “propTypes”.

1reaction
facebook-github-botcommented, Oct 11, 2017

Hey, thanks for reporting this issue! It looks like your description is missing some necessary information, or the list of reproduction steps is not complete. Can you please add all the details specified in the Issue Template? This is necessary for people to be able to understand and reproduce the issue being reported. I am going to close this, but feel free to open a new issue with the additional information provided. Thanks! See “What to Expect from Maintainers” to learn more.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'Proptypes' is not defined - Stack Overflow
I'm receiving the following linting error 'PropTypes' is not defined. (no-undef) . Here is the code that is causing the issue: import React,...
Read more >
[Solved]-'Proptypes' is not defined-Reactjs - appsloveworld
According to this issue comment. It appears to be because you have installed eslint 4.x when you should just use the eslint version...
Read more >
How to validate React props using PropTypes - LogRocket Blog
Learn how to validate props with React PropTypes, React's internal mechanism for adding type checking to component props.
Read more >
How to Use PropTypes in React - freeCodeCamp
PropTypes are simply a mechanism that ensures that the passed value is of the correct datatype. This makes sure that we don't receive...
Read more >
Typechecking With PropTypes - React
PropTypes exports a range of validators that can be used to make sure the data you receive is valid. In this example, we're...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found