react-dom-stream icon indicating copy to clipboard operation
react-dom-stream copied to clipboard

You are manually calling a React.PropTypes validation function

Open lalayueh opened this issue 9 years ago • 9 comments

After upgrading react to 15.3.0, it shows the following warning message via the server side rendering:

Warning: You are manually calling a React.PropTypes validation function for the head prop on Html. This is deprecated and will not work in the next major version. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details. Warning: You are manually calling a React.PropTypes validation function for the content prop on Html. This is deprecated and will not work in the next major version. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.

I think it may call PropTypes directly within the call path of renderToStaticMarkup The issue can be reproduced by the following code:

function renderComponent({ componentHtml, head }) {
  return renderToStaticMarkup(                            
    <Html                                                        
      content={componentHtml}             
      head={head}                      
    />
  );                                    
}   

Could you kindly help this issue. Thanks.

lalayueh avatar Aug 03 '16 10:08 lalayueh

+1

maxpain avatar Aug 13 '16 14:08 maxpain

+1

chenjia2015 avatar Aug 15 '16 06:08 chenjia2015

Same.

pasiba avatar Aug 28 '16 21:08 pasiba

Yup this is a pretty big issue because

If you don't fix the warning, this code will crash in production with React 16.

They even suggest an alternative.

If you depend on using PropTypes like this, we encourage you to use or create a fork of PropTypes (such as these two packages).

Alex-ray avatar Sep 07 '16 22:09 Alex-ray

There must be some good reason for this...surely they knew this would ruin SSR?

jedwards1211 avatar Sep 08 '16 21:09 jedwards1211

I was looking into this just to realise that react-dom-stream relies on a forked version of react which is on react 0.14.2. Between that and react 15.3.0 I am lost as to where to look for solution for the validation warning's.

nim23 avatar Sep 18 '16 16:09 nim23

Just run into a new issue by using ReactDOMStream:

Warning: Failed Context Types: Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types

Looks like the change is not too hard ?

GuillaumeCisco avatar Sep 25 '17 08:09 GuillaumeCisco

Any updates on this?

hakimelek avatar Dec 20 '17 19:12 hakimelek

If you are using react 16, it seems to me that you should better use the renderToNodeStream method from ReactDOMServer to fix this issue.

Reference: https://reactjs.org/docs/react-dom-server.html#rendertonodestream

lalayueh avatar Dec 25 '17 21:12 lalayueh