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

137
Vistas
how to convert this into a typescript

How to make this jsx in typescript. In javascript, it looks like this. But in typescript, I don't know how to achieve this exact code!

const Users = ({details,deleteUser}) => {
    return (
        <>
            <div>
            {details.map(detail => (
                <tr key={detail.del}>
                    <td>{detail.del}</td>
                    <td>{detail.name}</td>
                    <td>{detail.email}</td>
                    <td>{detail.pass}</td>
                    <td>{detail.contact}</td>
                    <td className='delete-btn' onClick={() => deleteUser(detail.del)}>
                        Delete
                    </td>
                </tr>
            ))}
            </div>
        </>
    )}
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

As first you should define your props type:

type User = {
  del: string;
  name: string;
  email: string;
  pass: string;
  contact: string;
};
type UsersProps = {
  details: User[];
  deleteUser: (del: string) => void;
};

After this you should apply the type to the component props:

const Users = (props: UsersProps) => {
    const {details,deleteUser} = props;
    return (
        <>
            <div>
            {details.map(detail => (
                <tr key={detail.del}>
                    <td>{detail.del}</td>
                    <td>{detail.name}</td>
                    <td>{detail.email}</td>
                    <td>{detail.pass}</td>
                    <td>{detail.contact}</td>
                    <td className='delete-btn' onClick={() => deleteUser(detail.del)}>
                        Delete
                    </td>
                </tr>
            ))}
            </div>
        </>
    )
};

In this way typescript will show you any typo, for example if you write detail.mail instead of detail.email ts will highlight it for you.

about 4 years ago · Juan Pablo Isaza Denunciar

0

At first, you need the interface of the User in typescript.

export default interface IUser {
   id: number,
   name: string,
   image: string,
   ...others
}

Then you need to define the passed parameters it should look like the User interface. So the code will be.

{details<IUser[]>.map(detail => (
                <tr key={detail.del}>
                    <td>{detail.del}</td>
                    <td>{detail.name}</td>
                    <td>{detail.email}</td>
                    <td>{detail.pass}</td>
                    <td>{detail.contact}</td>
                </tr>
            ))}
about 4 years ago · Juan Pablo Isaza Denunciar
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