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

446
Views
useParams() no obtiene el ID de usuario y se muestra indefinido en la consola cuando consuelo el ID de usuario

Estoy tratando de acceder al ID de usuario de un usuario desde la URL (la URL se parece a esto http://localhost:3000/user-profile/904900003354517617608).

cuando consuelo con el userId de usuario, se muestra undefined .

También he usado useParams en algunos otros componentes y funcionan correctamente, pero para useProfile está teniendo algún problema (también estoy usando cordura).

el código:

 const UserProfile = () => { const [user, setUser] = useState(null) const [pins, setPins] = useState(null) const [text, setText] = useState('Created') const [activebutton, setActivebutton] = useState('created') const navigate = useNavigate() const { userId } = useParams() console.log(userId) useEffect(() => { const query = userQuery(userId) client.fetch(query) .then((data) => { setUser(data[0]) }) }, [userId]) return ( <div className="relative pb-2 h-full justify-center items-center"> <div className="flex flex-col pb-5"> <div className="relative flex flex-col mb-7"> <div className="flex flex-col justify-center items-center"> <img src={randomImage} className="w-full h-370 2xl:h-510 shadow-lg object-cover" alt="Banner" /> <img className="rounded-full w-20 h-20 -mt-10 shadow-xl object-cover" src={user.image} alt="Profile-picture" /> </div> </div> </div> </div> ) } export default UserProfile
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Asegúrate de que tu ruta se vea así:

 <Route path="/user-profile/:userId" />
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!