React Tech Stack
Teach Stack & Project Structure
Last updated
Teach Stack & Project Structure
Last updated
State managementredux , redux-thunk , redux-persist , context-api
Css frameworktailwindcss , styled components , mui
optional : headlessui
Routerreact-router-dom
Http Request & Data Fetchingfetch (native js) , react-query
Table managementreact-table
Form managementreact-hook-form
Languaguereact-i18n
DeploymentBuild Docker file
TestJest(Unit Test)
Date picker
Mui Date Picker
Charting
Victory chart
Varible : CamelCase
Function : CamelCase
Varible Config : Screnming Snake Case
Component : Upper Camel Case
File , Folder : lower camel case,
Action Store : Screnming Snake Case
Type Interface or Type Assertions :
Use PascalCase for interface names.
Use camelCase for interface members.
Use "I" as a prefix for interface names.
Use "Props" end of interface name
State :Use "use" prefix for state name and use "set" prefix for setState
assets - ที่เก็บไฟล์ Static เช่น รูปภาพ , font
component - ที่เก็บไฟล์ component ต่างๆ
config - ที่เก็บ config หรือ ค่าคงที่ต่างๆ
Hoc - ที่เก็บไฟล์ HOC หรือ higher order component
hook - ที่เก็บไฟล์ custom hook
page - ที่เก็บไฟล์หน้าหลักของ page
route - ที่เก็บไฟล์สำหรับไว้สร้างหน้า route ต่างๆ
service - ที่เก็บไฟล์สำหรับเรียก service หรือ api
store - ที่เก็บไฟล์ของ store ใน redux
styles - ที่เก็บไฟล์สำหรับ custom css
__test__ - ที่เก็บไฟล์สำหรับเขียน unit test
themes - ที่เก็บไฟล์สำหรับ custom themes ของ tailwind
type - ที่เก็บไฟล์สำหรับ global type
utils - ที่เก็บไฟล์สำหรับฟั่งชั่นที่ใช้หลายๆที่
ใน folder pages จะแบ่ง folder ตามชื่อ หน้านั้นๆ(path) โดยแต่ละ folder path จะมี folder แยกย่อยดังนี้
components - สำหรับไฟล์ component ที่ใช้เฉพาะในหน้านั้นๆ
contexts - สำหรับไฟล์ context ที่ใช้เฉพาะในหน้านั้นๆ
types - สำหรับไฟล์ .ts ที่ใช้เฉพาะในหน้านั้นๆ
Design Component
อย่าพยามสร้าง component ที่ nested เกิน 3ขั้น ควรจะ compose ให้ได้มากที่สุด ถ้าเราพยายามที่จะ reuse โค๊ดมากเกินไป มันจะกลายเป็นทำให้ทุกอย่างมัน depend กันเกินไป เวลามี requried ใหม่ๆเข้ามามันไม่สามารถ scale ได้ดีเท่าที่ควร