- 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.tsxandindex.tsx. - Make
api.tsfile and define api functions. - Install react-query via npm,
npm i react-query. - Make
routesfolder. - Make
Home.tsxfile inroutesfolder and fetch all data you need by usingapi.tsandreact-query. - Make
componetsfolder. - Make
Coin.tsxfile incomponentsfolder and define theCoincomponent using props fromHome.tsx. - Make
Detail.tsxfile inroutesfolder and fetch all data you need by usingapi.tsandreact-query. - Install react-router-dom via npm,
npm i react-router-dom. - Make
Router.tsxfile and define routes forHome.tsxandDetail.tsx. - Add
Routercomponent toApp.tsxby importing it fromRouter.tsx. - Add
useParamsinDetail.tsxfile to getcoinIdparameter from url. - Install apexcharts.js via npm,
npm install apexcharts --save. - Make
Chart.tsxfile inroutesfolder and fetch all data you need by usingapi.tsandreact-query. - Link
Coincompenents inHome.tsxto navigate toDetail.tsx. - Make
BackComponents inDetail.tsxto navigate toHome.tsx. - Make
MoreDetailsComponents inDetail.tsx. - Make
TabinDetail.tsxshow and hideChart.tsxandMoreDetails.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
Helmetcomponent aboveRoutercomponent and embed the link that we copied in step 2. - Install styled-compents via npm,
npm install --save styled-components. - Make
stylesfolder. - Remove default settings in CSS. You can do this in various ways. In my case, define
createGlobalStyleinApp.tsxand copy and paste the code in here. - Make
styled.d.tsfile instylesfolder and declare module'styled-components'and add interfaceDefaultTheme. - Make
theme.tsfile instylesfolder and define colors in themes usingDefaultThemeyou want to use. In my case, I defineddarkThemeandlightTheme. - Make
global.d.tsfile insrcfolder 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.tsxfile instylesfolder, 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-pagesbranch 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.jsonand 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"toscriptinpackage.json. -
"scripts": { "deploy": "gh-pages -d build", "predeploy": "npm run build" },
-
Finish deployment by entering
npm run deployin the console.
Don't forget to add
basename={process.env.PUBLIC_URL}in your BrowserRouter










