Tsreact
Tsreact
REACT JS
THIS BOOK
This book is written (typed) by
Ari, who hails from the South
and has keen interests in
Computer Science, Biology,
and Tamil Literature.
Occasionally, he updates his
website, where you can reach
out to him.
https://arihara-sudhan.github.io
Intro and Installation
I hope you guys know
React JS, TypeScript and
JS very well or to an extent.
This is a prerequisite to get
the most out of this book.
As the title says, it is a kutty
book that describes the
interesting facets of React
with TypeScript. So, without
reading much, let’s get into
the installation part.
>> npx create-react-app teact --template typescript
It is not necessary to
import React (In 17+
versions or React).
If you want to make it
explicit, ah I mean clear to
newbies, just write the type
as FunctionComponent.
Here, we have to
comprehend where it will
be useful.
PROPS TYPE
Props can be strictly typed
as shown below.
Types such as
HTMLInputElement in are
predefined types that
represent various DOM
elements.
There are more like this...
Following includes an
example of defining an
event handler.
There are some such Event
Types.
CONTEXT API
To create a context in
TypeScript, we typically
start by defining the shape
of the context data and
then create the context
itself.
The context created can be
used accordingly.
THE PROJECT IS OUT
The Project I had a notion
to create is created! Check
it in my GitHub Repo: