Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

192
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda