This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Support pages/_document
as a function component
#19355
Milestone
You can continue the conversation there. Go to discussion →
pages/_document
as a function component
#19355
Feature request
Is your feature request related to a problem? Please describe.
Converting
_document
to a function component has no real benefits currently besides being able to useuseContext
but there's no context wrapper above _document that you can use with useContext.useState
,useEffect
, and other hooks will not work as well given that_document
is not hydrated client-side.Even though there are no benefits the question to support a function instead of a class comes up from time to time in #7515, hence why I'm creating this story.
Describe the solution you'd like
_document
is currently not a function component for backwards compat reasons, we can likely take a similar approach to what we did for _app though by having getInitialProps fall back to the default value.The text was updated successfully, but these errors were encountered: