Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
¿Hay alguna forma en Next.js de modularizar un elemento de página que recibe staticProps a través de un parsedUrlQuery?

El caso de uso es para abrir

http://localhost:3000/users/101

Así es como me gustaría que fuera el diseño de mi página y Element extraiga el segundo fragmento de código en [id].tsx

 import CTASection from '../../components/samples/CTASection'; import { User } from "../../interfaces"; import { GetStaticProps, GetStaticPaths } from "next"; import Element from "pages/users/element"; const Element = ({ item, errors }: Props) => { return ( <Box> <Element /> <CTASection /> </Box> ) } export default Id; export const getStaticPaths: GetStaticPaths = async () => { // Get the paths we want to pre-render based on users const paths = sampleUserData.map((user) => ({ params: { id: user.id.toString() }, })); return { paths, fallback: false }; }; export const getStaticProps: GetStaticProps = async ({ params }) => { try { const id = params?.id; const item = sampleUserData.find((data) => data.id === Number(id)); return { props: { item } }; } catch (error) { return { props: { errors: 'ERROR Loading Data' } }; } };

Sin embargo, solo representa los parámetros de consulta si inserto mi página element.tsx de una manera no modular como esta:

 ... return ( <Box> <Grid gap={2}> <Heading as="h2" fontSize={{ base: "lg", sm: "3xl" }}> Verifikation </Heading> <Box backgroundColor={colorMode === "light" ? "gray.200" : "gray.500"} padding={4} borderRadius={4} > <Box fontSize={textSize} title={`${ item ? item.name : "User Detail" }`}> {item && <ListDetail item={item} />} </Box> </Box> </Grid> <CTASection /> </Box> ) ...

Este es el ListDetail.tsx:

 import * as React from "react"; import { User } from "../../interfaces"; type ListDetailProps = { item: User; }; const ListDetail = ({ item: user }: ListDetailProps) => ( <div> <h1>User: {user.name}</h1> <p>ID: {user.id}</p> </div> ); export default ListDetail;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

puedes usar gerServerSideProps

 export const getServerSideProps = async ({ req, res, query, params }) => { // your code... // you have access to req, res, query, params, headers, cookies, and many more. return { props: {} } }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!