Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

184
Vistas
The ID of object in my react js app didn't configure well

Every object that I click, will give me this link: http://localhost:3000/edit/$%7Buser.id%7D

It supposed to give an id of each object that I click, but it doesn't.

User.js List

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>
    )
}

The error: enter image description here

What went wrong cause of this?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda