M
M
miliko mikoyan2019-06-15 12:28:13
typescript
miliko mikoyan, 2019-06-15 12:28:13

How do I write the content attribute in react?

this is my code

<div  itemProp={"offers"} itemScope  itemType={"http://schema.org/Offer"}>
        <span  itemProp="price" content="10.00">{10}</span>
 </div>

I am getting this error.
Type '{children:string; itemProp: string content: string; } ' cannot be assigned to type 'DetailHTMLProps, HTMLSpanElement>'. Content property does not exist for type 'DetailHTMLProps, HTMLSpanElement>'.
I think the problem is content.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2019-06-15
@miliko0022

Alternatively, you can use this hack:
sometimes it is convenient to define properties in a variable:

const spanProps = {
  itemProp: 'price',
  content: '10.00',
};

return (
  <span {...spanProps}>10</span>
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question