I have seen the dubious "ctx" object in React sometimes as a parameter, like in this _app.js: https://spectrum.chat/next-js/general/fetch-data-once-in-app-js~d76c5ea2-1a6f-4719-b476-a05765c726d1
and I am wondering what it exactly is and where does it come from, as I have seen no good documentation about what it is... is it the same as props passed to some react component?
ctx
is a NextJS artifact. It is not part of standard React.
ctx
is a context object containing those properties (Source):
pathname
- path section of URLquery
- query string section of URL parsed as an objectasPath
- String of the actual path (including the query) shows in the browserreq
- HTTP request object (server only)res
- HTTP response object (server only)err
- Error object if any error is encountered during the renderingThis may also help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With