Last active
July 5, 2024 16:50
-
-
Save jspw/b4ff03281dbc89cd5a7266b5e30eeab1 to your computer and use it in GitHub Desktop.
Revisions
-
jspw renamed this gist
Jul 5, 2024 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jspw renamed this gist
Jul 5, 2024 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ ## JavaScript ## React @@ -31,7 +31,7 @@ ### Low Level Code - Inside a react component ---> ` define variables -> define states -> define methods/functions -> hooks (useMemo() -> useEffect()) ` Example: -
jspw created this gist
Jul 5, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,98 @@ # Code Conventions ## Java ## Springboot ## JavaScript ## React ### Filename related - React Component files -> `.tsx` - All other files such as interface, utility, constant files -> `.ts` - React Component’s naming convention -> `SampleComponent.tsx` - Normal typescript file naming convention -> `sampleFile.ts` ### Low Level Code - Inside a react component --- ` define variables -> define states -> define methods/functions -> hooks (useMemo() -> useEffect()) ` Example: ```ts export const SampleComponent = () => { // variables const totalPages = 2; //states const [count, setCount] = useState<number>(0) const [result, setResult] = useState(0) const [height, setHeight] = useState(0) const [width, setWidth] = useState(0) // methods const handleCountIncrease = () => setCount(pre => pre + 1) const handleCountDecrease = () => setCount(pre => pre - 1) const area = (height: number, width: number) => { setResult(2 * height * width) } //hooks const renderData = useMemo(() => <div>Area : {result}</div>, [result]) useEffect(() => { area(height, width) }, [height, width]) return renderData } ``` ## ExpressJs