facebook / prop-types

Runtime type checking for React props and similar objects
MIT License
4.48k stars 356 forks source link

Typo in static class property declaration react/no-typos #264

Closed shmatapour closed 5 years ago

shmatapour commented 5 years ago

Hi guys, I installed PropTypes and used it on my project , I encountered with below error : err

Please guide me how to solve it if you know, Thanks.

ljharb commented 5 years ago

it's .propTypes, not .PropTypes. The rule just saved you from a bug.

abid102 commented 5 years ago

same problem occured to me please help me but i gave .propTypes this only.i new to react Thanks in Advance

ljharb commented 5 years ago

@abid102 please file a new issue.

maniranganathan97 commented 4 years ago

Please, anyone, suggest the answer because I am also facing the same problem

maniranganathan97 commented 4 years ago

I found the Answer propTypes and not proptypes

Happy Coding!!!!!!

Danielchucks commented 4 years ago

I had the same issue, the bug is from the naming convention. .propTypes not .PropTypes. Thank You ljharb.

juancolchete commented 4 years ago

Thank you ljharb.

thobishi commented 4 years ago

Thanks, This also worked for me.

yogesh1008 commented 4 years ago

Thank you ljharb.

yogesh1008 commented 4 years ago

Thanks, This also worked for me.

krishnadevz commented 4 years ago
import propTypes from 'prop-types';

and use propTypes as @ljharb said it worked ❤🐱‍💻

classyeze commented 4 years ago

thanks it worked..

jorgearimitsu commented 4 years ago
import propTypes from 'prop-types';

and use propTypes as @ljharb said it worked ❤🐱‍💻

Actually you can follow the docs.

import PropTypes from 'prop-types';

and then

Component.propTypes = {
  myProp: PropTypes.array.isRequired
}

It's Component.propTypes not Component.PropTypes

Yes... I know... 🙄

omfuke commented 4 years ago

.propTypes worked for me instead of .PropTypes

virtuousved commented 4 years ago

keep import as

 import PropTypes from 'prop-types';

and then to add a property to component use

Todos.propTypes = {}

This has worked for me. See the cases of proptypes in both the places

gnsalok commented 4 years ago
import PropTypes from 'prop-types';

Todos.propTypes = {
// your code
};
peepsenpai commented 3 years ago

@ljharb whats the difference between .propTypes and .PropTypes ? i need ans man, can't sleep without knowing

ljharb commented 3 years ago

@peepsenpai one starts with a lowercase P and the other starts with a capital P, and only one of them is correct. Get some rest!

Krishna-sm commented 2 years ago

image do this Component.propTypes={ props:PropTypes.string};