Cannot find namespace 'ctx' error when creating Context with react - typescript

前端 未结 2 1526
死守一世寂寞
死守一世寂寞 2021-01-07 16:38

I\'m working on a project with react using typescript and I\'m having a bad time figuring out why this error is happening, basically, I can\'t use

相关标签:
2条回答
  • 2021-01-07 17:28

    Please use tsx instead of ts it has some minute differences. tsx obviously allows the usage of jsx tags inside typescript.

    0 讨论(0)
  • 2021-01-07 17:29

    Your file extension is most likely .ts instead of .tsx.

    Therefore TypeScript is interpreting <ctx.Provider as cast and tries to find a type Provider in the namespace ctx.

    0 讨论(0)
提交回复
热议问题