- Purpose: Fetch cryptocurrency data
- Guide: api.coinpaprika.com
- Initialize project using Create React App,
npx create-react-app my-app --template typescript
. - Erase useless files, in my case I delete all the files except
App.tsx
andindex.tsx
. - Make
api.ts
file and define api functions. - Install react-query via npm,
npm i react-query
. - Make
routes
folder. - Make
Home.tsx
file inroutes
folder and fetch all data you need by usingapi.ts
andreact-query
. - Make
componets
folder. - Make
Coin.tsx
file incomponents
folder and define theCoin
component using props fromHome.tsx
. - Make
Detail.tsx
file inroutes
folder and fetch all data you need by usingapi.ts
andreact-query
. - Install react-router-dom via npm,
npm i react-router-dom
. - Make
Router.tsx
file and define routes forHome.tsx
andDetail.tsx
. - Add
Router
component toApp.tsx
by importing it fromRouter.tsx
. - Add
useParams
inDetail.tsx
file to getcoinId
parameter from url. - Install apexcharts.js via npm,
npm install apexcharts --save
. - Make
Chart.tsx
file inroutes
folder and fetch all data you need by usingapi.ts
andreact-query
. - Link
Coin
compenents inHome.tsx
to navigate toDetail.tsx
. - Make
Back
Components inDetail.tsx
to navigate toHome.tsx
. - Make
MoreDetails
Components inDetail.tsx
. - Make
Tab
inDetail.tsx
show and hideChart.tsx
andMoreDetails.tsx
. Done.
Please dont' care about the coloring things in this stage, just fetch and show data.
- Design it with design tools or something, in my case Figma.
- Visit Google Fonts and select the fonts you want to use. Copy the
<link>
to embed. - Install react-helmet via npm,
npm install --save react-helmet
. - Add
Helmet
component aboveRouter
component and embed the link that we copied in step 2. - Install styled-compents via npm,
npm install --save styled-components
. - Make
styles
folder. - Remove default settings in CSS. You can do this in various ways. In my case, define
createGlobalStyle
inApp.tsx
and copy and paste the code in here. - Make
styled.d.ts
file instyles
folder and declare module'styled-components'
and add interfaceDefaultTheme
. - Make
theme.ts
file instyles
folder and define colors in themes usingDefaultTheme
you want to use. In my case, I defineddarkTheme
andlightTheme
. - Make
global.d.ts
file insrc
folder and declare modules to use image files. - Show off your CSS skills! Make styled components in the files you need. If you have to make a identical styled
components in different files, make
styles.tsx
file instyles
folder, put them there, and import them where you need.
Please don't just copy my design or code. That doesn't help you at all.
-
You can deploy your website in various ways. In my case, I deployed by publishing files to
gh-pages
branch on GitHub. -
Make Repository on GitHub and push all the files.
-
Install gh-pages via npm,
npm install gh-pages --save-dev
. -
Go to
package.json
and add"homepage"
right above the last curly brace. Usehttps://user-id-here.github.io/repository-name-here
-
}, "homepage": "https://codeisneverodd.github.io/practice-with-react-typescript-for-crypto-dictionary/" }
-
Add
"deploy"
and"predeploy"
toscript
inpackage.json
. -
"scripts": { "deploy": "gh-pages -d build", "predeploy": "npm run build" },
-
Finish deployment by entering
npm run deploy
in the console.
Don't forget to add
basename={process.env.PUBLIC_URL}
in your BrowserRouter