You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a renderProp function renders null I see the following react warning being logged at stdout:
Warning: Failed prop type: The prop `children` is marked as required in `SimpleSFCWrapper`, but its value is `null`.
in SimpleSFCWrapper
Expected behavior
I wouldn’t expect to see such a warning since everything works just fine when using null. Also see the react documentation which says null can be used to render nothing.
Your environment
I’ve created a minimal example to reproduce this issue:
run npm i react@16.8.3 enzyme@3.9.0 enzyme-adapter-react-16@1.11.2 react-dom@16.8.3
create a file test.js which the following content:
In our project we use the Query component from apollo-client to perform GraphQL queries, handle the loading state and showing the data when it is ready. The children prop of Query is a renderProp function which gets the query state as an argument. The query state contains information about the loading state or if the data has been loaded it contains the data.
In some cases we just want to render nothing while the data is still loading.
Example:
// ... within a componentrender(){return(<Queryquery={anyGraphqlQuery}>{({ loading, data })=>{if(loading){returnnull;}return<div>{data.foo}</div>;}}</Query>);}// ...
The text was updated successfully, but these errors were encountered:
Follow-up of #2030.
Current behavior
When a
renderProp
function rendersnull
I see the following react warning being logged at stdout:Expected behavior
I wouldn’t expect to see such a warning since everything works just fine when using
null
. Also see the react documentation which saysnull
can be used to render nothing.Your environment
I’ve created a minimal example to reproduce this issue:
npm i react@16.8.3 enzyme@3.9.0 enzyme-adapter-react-16@1.11.2 react-dom@16.8.3
test.js
which the following content:node test.js
API
Version
Adapter
Real-World Use-Case
In our project we use the
Query
component from apollo-client to perform GraphQL queries, handle the loading state and showing the data when it is ready. Thechildren
prop ofQuery
is arenderProp
function which gets the query state as an argument. The query state contains information about the loading state or if the data has been loaded it contains the data.In some cases we just want to render nothing while the data is still loading.
Example:
The text was updated successfully, but these errors were encountered: