From 3a87d09933c8ecac551cd11d4572fb1662c62d60 Mon Sep 17 00:00:00 2001 From: aleidk Date: Mon, 4 Sep 2023 23:17:19 -0300 Subject: [PATCH] Update from obsidian - thinkpad Affected files: .obsidian/workspace.json games/castlevania-symphony-of-the-night.md notes/utils/React.md projects/games.md --- .obsidian/workspace.json | 29 ++++++++--- games/castlevania-symphony-of-the-night.md | 8 ++- notes/utils/React.md | 57 +++++++++++++++++++++- projects/games.md | 54 ++++++++++++-------- 4 files changed, 119 insertions(+), 29 deletions(-) diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index e98b495..9ca1819 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -18,8 +18,21 @@ }, "pinned": true } + }, + { + "id": "90eeecc802a23d24", + "type": "leaf", + "state": { + "type": "markdown", + "state": { + "file": "games/castlevania-symphony-of-the-night.md", + "mode": "source", + "source": false + } + } } ], + "currentTab": 1, "stacked": true } ], @@ -86,7 +99,7 @@ "state": { "type": "backlink", "state": { - "file": "projects/games.md", + "file": "games/castlevania-symphony-of-the-night.md", "collapseAll": false, "extraContext": false, "sortOrder": "alphabetical", @@ -103,7 +116,7 @@ "state": { "type": "outgoing-link", "state": { - "file": "projects/games.md", + "file": "games/castlevania-symphony-of-the-night.md", "linksCollapsed": false, "unlinkedCollapsed": true } @@ -126,7 +139,7 @@ "state": { "type": "outline", "state": { - "file": "projects/games.md" + "file": "games/castlevania-symphony-of-the-night.md" } } }, @@ -159,8 +172,12 @@ "dbfolder:Create a new database table": false } }, - "active": "fefb57826a3809d6", + "active": "90eeecc802a23d24", "lastOpenFiles": [ + "notes/utils/React.md", + "projects/games.md", + "games/a-hat-in-time.md", + "games/monster-hunter-4-ultimate.md", "games/zero-escape-zero-time-dilemma.md", "games/zero-escape-virtue-s-last-reward.md", "games/zero-escape-nine-hours-nine-persons-nine-doors.md", @@ -183,10 +200,6 @@ "games/omori.md", "games/mirrors-edge-catalyst.md", "games/mirror-s-edge.md", - "games/kaze-and-the-wild-masks.md", - "games/it-takes-two.md", - "games/into-the-breach.md", - "games/indivisible.md", "games/castlevania-symphony-of-the-night", "igdb", "projects/radio-notes", diff --git a/games/castlevania-symphony-of-the-night.md b/games/castlevania-symphony-of-the-night.md index 274de6e..3c72949 100644 --- a/games/castlevania-symphony-of-the-night.md +++ b/games/castlevania-symphony-of-the-night.md @@ -49,4 +49,10 @@ So how or why did it move?? I waited some time and... it moved it on it's own... I pause the game and yea, it's my playtime, I have been playing for 1 hours and 25 minutes, and that clock interacts with it. -I think that's brilliant, I big landmark (even more since there is the first time you encounter with maria), someplace you really remember, and a pourpose to get back to it eventually. I'm waiting to pass the 2 hours to go back and see what's happend when the hours and minutes are even, maybe nothing, but it's a little adventure to look forward to, and that is what make a metroidvania so good \ No newline at end of file +I think that's brilliant, I big landmark (even more since there is the first time you encounter with maria), someplace you really remember, and a pourpose to get back to it eventually. I'm waiting to pass the 2 hours to go back and see what's happend when the hours and minutes are even, maybe nothing, but it's a little adventure to look forward to, and that is what make a metroidvania so good + +--- + +La ubicación de las mejoras es extraña, es como "random" y en lugares super poco significativos, en un pasiillo nada más o algo por el estilo. Además he recorrido un buen trazo del castillo y solo he podido usar el doble salto, el lobo no lo he podido usar + +Esto tiene algo positivo y negativo, he tenido poquitos momentos de "Ajá!, ahora puedo ir a este lugar que recuerdo", pero he tenido muchos momentos de "no encuentro nada por aqui, revisaré en otro lado" y me topo con un camino que no me había dado cuenta, reigniting my adventuring spirit \ No newline at end of file diff --git a/notes/utils/React.md b/notes/utils/React.md index 51de7d3..1c8e6fe 100644 --- a/notes/utils/React.md +++ b/notes/utils/React.md @@ -1,3 +1,58 @@ ## Typescript -- [Cheatsheet](https://react-typescript-cheatsheet.netlify.app) \ No newline at end of file +- [Cheatsheet](https://react-typescript-cheatsheet.netlify.app) + +## Prevent UseEffect Infinite Loops + +React use [shallow comparision](https://learntechsystems.com/what-is-shallow-comparison-in-js/) (values are equals in case of primitive types. In case of object it just check the reference) to check if the dependency changes between renders, this can conduce to bugs in the following situa + +### Always use a depency array + +```js +useEffect(() => { + setCount((count) => count + 1); +}, []); +``` + +### Function as dependency + +React re defines functions on every render, so the dependency always changes, use `useCallback` to memoize the function so it doesn't change + +```js +const logResult = useCallback(() => { + return 2 + 2; +}, []); + +useEffect(()=> { + setCount((count) => count + 1); +}, [logResult]); +``` + +### Array as dependency + +The reference to an array changes in every render, use `useRef` so it doesn't change + +```js +const [count, setCount] = useState(0); +//extract the 'current' property and assign it a value +const { current: myArray } = useRef(["one", "two", "three"]); + +useEffect(() => { + setCount((count) => count + 1); +}, [myArray]); +``` +### Object as dependency + +The reference to an object changes in every render, use `useMemo` so it doesn't change + +```js +const person = useMemo( + () => ({ name: "Rue", age: 17 }), + [] //no dependencies so the value doesn't change +); +useEffect(() => { + setCount((count) => count + 1); +}, [person]); +``` + +[source](https://blog.logrocket.com/solve-react-useeffect-hook-infinite-loop-patterns/) diff --git a/projects/games.md b/projects/games.md index 97824d1..8731fc3 100644 --- a/projects/games.md +++ b/projects/games.md @@ -183,7 +183,7 @@ columns: persist_changes: false footer_formula: franchises: - input: tags + input: select accessorKey: franchises key: franchises id: franchises @@ -194,24 +194,40 @@ columns: sortIndex: -1 width: 230 options: - - { label: "None", value: "None", color: "hsl(268, 95%, 90%)"} - - { label: "Bloodstained", value: "Bloodstained", color: "hsl(213, 95%, 90%)"} - - { label: "Doom", value: "Doom", color: "hsl(164, 95%, 90%)"} - - { label: "Mega Man", value: "Mega Man", color: "hsl(302, 95%, 90%)"} - - { label: "Metroid", value: "Metroid", color: "hsl(357, 95%, 90%)"} - - { label: "Monster Hunter", value: "Monster Hunter", color: "hsl(14, 95%, 90%)"} - - { label: "Megami Tensei", value: "Megami Tensei", color: "hsl(270, 95%, 90%)"} - - { label: "Shin Megami Tensei", value: "Shin Megami Tensei", color: "hsl(350, 95%, 90%)"} - - { label: "Persona", value: "Persona", color: "hsl(236, 95%, 90%)"} - - { label: "Portal", value: "Portal", color: "hsl(157, 95%, 90%)"} - - { label: "Resident Evil", value: "Resident Evil", color: "hsl(234, 95%, 90%)"} - - { label: "Sonic The Hedgehog", value: "Sonic The Hedgehog", color: "hsl(297, 95%, 90%)"} - - { label: "Star Wars", value: "Star Wars", color: "hsl(123, 95%, 90%)"} - - { label: "Steins;Gate", value: "Steins;Gate", color: "hsl(140, 95%, 90%)"} - - { label: "Mario Bros.", value: "Mario Bros.", color: "hsl(275, 95%, 90%)"} - - { label: "Mario", value: "Mario", color: "hsl(278, 95%, 90%)"} - - { label: "Valkyria", value: "Valkyria", color: "hsl(35, 95%, 90%)"} - - { label: "Zero Escape", value: "Zero Escape", color: "hsl(130, 95%, 90%)"} + - { label: "[,Megami Tensei,Persona]", value: "[,Megami Tensei,Persona]", color: "hsl(276, 95%, 90%)"} + - { label: "[,Mega Man]", value: "[,Mega Man]", color: "hsl(257, 95%, 90%)"} + - { label: "Monster Hunter", value: "Monster Hunter", color: "hsl(164, 95%, 90%)"} + - { label: "[,None]", value: "[,None]", color: "hsl(157, 95%, 90%)"} + - { label: "[,Shin Megami Tensei,Megami Tensei]", value: "[,Shin Megami Tensei,Megami Tensei]", color: "hsl(127, 95%, 90%)"} + - { label: "[,Megami Tensei]", value: "[,Megami Tensei]", color: "hsl(358, 95%, 90%)"} + - { label: "[,Persona,Megami Tensei]", value: "[,Persona,Megami Tensei]", color: "hsl(104, 95%, 90%)"} + - { label: "[,Shin Megami Tensei]", value: "[,Shin Megami Tensei]", color: "hsl(255, 95%, 90%)"} + - { label: "[,Mario Bros.,Mario]", value: "[,Mario Bros.,Mario]", color: "hsl(66, 95%, 90%)"} + - { label: "[,Metroid]", value: "[,Metroid]", color: "hsl(357, 95%, 90%)"} + - { label: "[,Bloodstained]", value: "[,Bloodstained]", color: "hsl(258, 95%, 90%)"} + - { label: "[,Doom]", value: "[,Doom]", color: "hsl(79, 95%, 90%)"} + - { label: "[,Portal]", value: "[,Portal]", color: "hsl(249, 95%, 90%)"} + - { label: "[,Resident Evil]", value: "[,Resident Evil]", color: "hsl(254, 95%, 90%)"} + - { label: "[,Sonic The Hedgehog]", value: "[,Sonic The Hedgehog]", color: "hsl(76, 95%, 90%)"} + - { label: "[,Star Wars]", value: "[,Star Wars]", color: "hsl(156, 95%, 90%)"} + - { label: "[,Steins;Gate]", value: "[,Steins;Gate]", color: "hsl(282, 95%, 90%)"} + - { label: "[,Valkyria]", value: "[,Valkyria]", color: "hsl(170, 95%, 90%)"} + - { label: "[,Zero Escape]", value: "[,Zero Escape]", color: "hsl(332, 95%, 90%)"} + - { label: "[,,None]", value: "[,,None]", color: "hsl(174, 95%, 90%)"} + - { label: "[,,Monster Hunter]", value: "[,,Monster Hunter]", color: "hsl(124, 95%, 90%)"} + - { label: "[,,Megami Tensei]", value: "[,,Megami Tensei]", color: "hsl(67, 95%, 90%)"} + - { label: "[,,Shin Megami Tensei,Megami Tensei]", value: "[,,Shin Megami Tensei,Megami Tensei]", color: "hsl(352, 95%, 90%)"} + - { label: "[,,Megami Tensei,Persona]", value: "[,,Megami Tensei,Persona]", color: "hsl(135, 95%, 90%)"} + - { label: "[,,Persona,Megami Tensei]", value: "[,,Persona,Megami Tensei]", color: "hsl(315, 95%, 90%)"} + - { label: "[,,Portal]", value: "[,,Portal]", color: "hsl(211, 95%, 90%)"} + - { label: "[,,Resident Evil]", value: "[,,Resident Evil]", color: "hsl(34, 95%, 90%)"} + - { label: "[,,Shin Megami Tensei]", value: "[,,Shin Megami Tensei]", color: "hsl(105, 95%, 90%)"} + - { label: "[,,Sonic The Hedgehog]", value: "[,,Sonic The Hedgehog]", color: "hsl(20, 95%, 90%)"} + - { label: "[,,Star Wars]", value: "[,,Star Wars]", color: "hsl(52, 95%, 90%)"} + - { label: "[,,Steins;Gate]", value: "[,,Steins;Gate]", color: "hsl(264, 95%, 90%)"} + - { label: "[,,Mario Bros.,Mario]", value: "[,,Mario Bros.,Mario]", color: "hsl(103, 95%, 90%)"} + - { label: "[,,Metroid]", value: "[,,Metroid]", color: "hsl(324, 95%, 90%)"} + - { label: "[,Monster Hunter]", value: "[,Monster Hunter]", color: "hsl(137, 95%, 90%)"} config: enable_media_view: true link_alias_enabled: true