score:1
Accepted answer
i've got it, you have an error in your _app
:
import '../styles/index.scss';
import 'bootstrap/dist/css/bootstrap.min.css';
// don't need to spread pageprops here
const myapp = ({ component, ...pageprops }) => {
return <component {...pageprops} />;
};
export default myapp;
it should be:
const myapp = ({ component, pageprops }) => {
return <component {...pageprops} />;
};
score:0
why dont use it like the code shown below
export default function firstpost({ id }) {
console.log("-->", id);
return (
<>
{id}sdlfdfdlkj
</>
);
}
firstpost.getinitialprops = ({ query }) => {
return { id: query?.id };
};
Source: stackoverflow.com
Related Query
- Nextjs getInitialProps query.id is undefined
- Why is this NextJS query string undefined on subsequent page reloads?
- NextJS - Appending a query param to a dynamic route
- Nextjs redux, thunk and getInitialProps - how to implement
- Pass object to query on Router.push NextJs
- Why would a query param be undefined in NextJS?
- NextJS bug: Component props are undefined when building the project (everything works fine on dev mode)
- Next.js router is returning query parameters as undefined on first render?
- Persist query string parameters in NextJS when navigating client side
- NextJS process.env. variables undefined on button click fetch data
- Nextjs React SSR with styled-jsx - Cannot read property 'state' of undefined
- Nextjs getInitialProps not working with NGINX
- nextjs complains about read property of undefined during build
- cannot read property 'dispatch' of undefined in nextjs
- Error cannot read property getState of undefined - Redux with NextJS
- how to access router params in getInitialProps stateles component in nextjs
- How to set nextjs router query parameter
- Losing query string by refreshing page in Nextjs using express
- How do I pass a custom parameter to nextjs dynamic route so I can access it inside getInitialProps
- React Apollo Testing is not working. Query data is always coming undefined
- Apollo Cache - Missing selection set for object of type undefined returned for query field names
- NextJS + Contentful => getEntries request within getInitialProps breaks production build
- Next/React-Apollo: React props not hooked up to apollo cache when query comes from getInitialProps
- Using NextJS to do SSR with Class Components and getInitialProps, render method has undefined data
- NextJS navigation to same page and different query wont trigger hooks
- React query infinite scroll pageParams is undefined
- How to get the query params inside getServerSideProps in nextjs
- Access store in getInitialProps with redux persist in nextjs
- localStorage.getItem() react returning undefined before graphql query
- Cannot read property 'indexOf' of undefined in NextJS server
More Query from same tag
- Alternatives to the Query-string managing state
- React native async/wait not waiting
- Snap.svg easing in Gatsby
- How to pass props to multiple dumb components - redux / reactJs?
- Warning: Received `false` for a non-boolean attribute `border`. in react?
- Error: Actions must be plain objects. But i'm not using async calls
- Dynamically creating a new component based off another component's state
- Next.js Reference Error - PDFtron Webviewer
- How to iteratively add Form.Item in Form.Item in ant design Form
- Unhandled Rejection (TypeError): ships.reduce is not a function
- React - CSS Transition like a book page
- How can I mock window.screen.width property?
- Webpack is taking 30 seconds to compile
- nested url routing using react-router and webpack dev server
- Reinstalling a git repository as a React Package
- How to display data from a weather api in React?
- Cypress.io Identity Server
- Sending data from a form in React to DyanmoDB via AWS Lambda with Node
- Can a website work with both simple JavaScript and React
- Rendering state json in React
- Input text child component does not show any text while typing passing onChange function from parent component
- Stop event listening after route change
- How can I display the button only once?
- Dynamically render routes in react-router 5.1
- Testing/Mocking ReactComponent SVG imports with Jest
- Switch to npm for create-react-app
- Error Exporting a component without importing
- JSX conditional rendering
- test onChange event in enzyme and jest with refs
- How to change name of a tag in react js