reactjs / react.dev

The React documentation website
https://react.dev/
Creative Commons Attribution 4.0 International
11.03k stars 7.53k forks source link

Note on PropTypes docs that directs users to prop-types can be confusing for new users #3632

Open scott-ln opened 3 years ago

scott-ln commented 3 years ago

I was looking for the docs on how to use defaultProps and found the PropTypes docs. The first thing I saw there was the yellow box at the top that says:

Note: React.PropTypes has moved into a different package since React v15.5. Please use the prop-types library instead.

I read this as meaning "this page is out of date, please see those docs", especially because the yellow box looks so important, and went to that package, which has much less comprehensive documentation. (Including no mention of defaultProps currently, although that's going to be fixed.) I didn't understand until re-reading it the next day that it was intended for people using PropTypes under its old name and I was supposed to carry on reading the page.

I suspect that I may not be the only learner prone to this kind of misreading, so may I please suggest that you move the note to a little further down the page and possibly tweak the wording? Thank you.

eps1lon commented 3 years ago

I was looking for the docs on how to use defaultProps and found the PropTypes docs.

The first result on the docs search links to "Declaring Default Props" which seems like the desired result. Only the second result links to PropTypes docs but to a fragment way below the yellow warning.

I don't know how we would make it more obvious that PropTypes is not the same as defaultProps.

scott-ln commented 3 years ago

This is how I found the page, rather than the docs search:

image

For me the note is placed too prominently, I would have put it under the third paragraph ("PropTypes exports a range..."). I'm really used to getting old docs from search results and following redirections to newer versions, which is frequently what that top space is used for - which is why I interpreted it that way at first glance.

Either way, about the text, I would change it to:

Note for users of React.PropTypes before React v15.5: React.PropTypes has moved into a different package. Please use the prop-types library instead.

That would make it clear to learners that they can continue reading rather than having to act on it.

eps1lon commented 3 years ago

These sentences seem the same to me. I don't follow what you changed or how this is clearer (apart from "it seems clearer to me personally"). The feedback is still appreciated though.

scott-ln commented 3 years ago

Thanks - I'm just trying to be clear for people who've never encountered it before that this note doesn't apply to them, you know? As a newb, this is how I read the existing notice:

If it had said "Note for users of React.PropTypes before React v15.5", I would have known it wasn't talking to me. I guess the last sentence could be "If you're still using it, please use the prop-types library instead". That conditional makes it unambiguous.

scottdotweb commented 2 years ago

Hello, it's me again. That was my old work account and Reasons prevented my submitting a PR for your consideration. I have now.

scottdotweb commented 2 years ago

As noted in a comment on that PR, I completely had the wrong end of the stick here, please ignore everything I said above. I can't close this issue myself so if someone please could - thanks!