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

174
Vistas
Type '{ author: Author; }' is not assignable to type 'IntrinsicAttributes & Author'

I am totally new to TS and react and I ran into a problem. I tried searching many places and can't seem to fix it. The whole error message is: Type '{ author: Author; }' is not assignable to type 'IntrinsicAttributes & Author'. Property 'author' does not exist on type 'IntrinsicAttributes & Author'.ts(2322) and my code is

import React from "react"

interface Data{
  author: Author;
  date:string;
  text:string;

}

interface Author{
  avatarUrl: string;
  name: string;

}
const Comment :React.FC<Data> =({author,text,date})=>{

  return (
    <div className="Comment">
      <div className="UserInfo">
        <Avatar author={author} />
       <div className="UserInfo-name">
          {author.name}
    </div>

  </div>
  <div className="Comment-text">
    {text}
  </div>
  <div className="Comment-date">
    {date}
  </div>
</div>


)
}


  
const Avatar:React.FC<Author> = ({
  avatarUrl,
  name
} ) =>{
  return(
      <img className="Avatar"
        src={avatarUrl}
        alt={name}
      />
  
  )
}
const App = () =>{
  const data = {
    date:"2017:11:07",
    text:"Some text is here",
    author:{
      avatarUrl:"https://images.unsplash.com/photo-1554080353-a576cf803bda?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8M3x8cGhvdG98ZW58MHx8MHx8&w=1000&q=80",
      name:"teleph0nes"
    }

  }
  return(
    <>
    <Comment author={data.author}
    text = {data.text}
    date={data.date}
    

/>
</>
  )
}

export default App
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You declare Avatar as this:

const Avatar:React.FC<Author> = ({

And the Author type as this:

interface Author{
  avatarUrl: string;
  name: string;
}

Which means that Avatar will expect two props avatarUrl and name. But you are passing it a prop named author.

If you want Avatar to receive an author prop, then you have to declare that in the type with something like:

const Avatar:React.FC<{ author: Author }> = ({ author }) => {

Which does what you expect.

See playground

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