I am using Typescript with NextJS, i want to add tabIndex = '0'
in one of the div. but am getting this error Type 'string' is not assignable to type 'number'
... how to achive this?
‹div className= 'container' tabIndex = '0'>
I am using Typescript with NextJS, i want to add tabIndex = '0'
in one of the div. but am getting this error Type 'string' is not assignable to type 'number'
... how to achive this?
‹div className= 'container' tabIndex = '0'>
Share
Improve this question
edited Aug 4, 2022 at 4:41
coagmano
5,6711 gold badge30 silver badges41 bronze badges
asked Aug 4, 2022 at 4:36
MarkMark
971 silver badge8 bronze badges
1
- Hi @Mark, for future questions please write the code into a code block instead of linking to a screenshot. I've edited this question to do so now – coagmano Commented Aug 4, 2022 at 4:43
2 Answers
Reset to default 10Instead of tabIndex='0'
, you should write it as tabIndex={0}
. This way Ty[escript will understand.
<div className="container tabIndex={0}>
I think typescript is wrong here, since it ends up as a string in html anyway.
But to please the piler, pass tabIndex
as a JS value like this:
<div className="container tabIndex={0}>