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

182
Views
La ID del objeto en mi aplicación reaccionar js no se configuró bien

Cada objeto en el que haga clic me dará este enlace: http://localhost:3000/edit/$%7Buser.id%7D

Se supone que debe dar una identificación de cada objeto en el que hago clic, pero no lo hace.

Lista de usuario.js

 import React, { useContext} from 'react'; import { GlobalContext } from '../context/GlobalState'; import { Link } from 'react-router-dom'; import { ListGroup, ListGroupItem, Button } from 'reactstrap'; export const UserList = () => { const { users } = useContext(GlobalContext); return ( <ListGroup className='mt-3'> {users.map(user => ( <ListGroupItem > <strong>{user.name}</strong> <div style={{ float: "right"}}> <Link className='btn btn-warning mr-1' to={'/edit/${user.id}'}>Edit</Link> <Button color='danger' style={{ marginLeft: "10px"}}>Delete</Button> </div> </ListGroupItem> ))} </ListGroup> ) }

GlobalState.js

 import React, { createContext, useReducer} from 'react'; import AppReducer from './AppReducer'; // Inisial State const initialState = { users: [ {id: 1, name: 'user one'}, {id: 2, name: 'user two'}, {id: 3, name: 'user three'} ] }; export const GlobalContext = createContext(initialState); // Provider Component export const GlobalProvider = ({children}) => { const [state, dispatch] = useReducer(AppReducer, initialState); return ( <GlobalContext.Provider value={{ users: state.users }}> {children} </GlobalContext.Provider> ) }

El error: ingrese la descripción de la imagen aquí

¿Qué salió mal por esto?

about 4 years ago · Juan Pablo Isaza
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!