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

194
Views
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
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!