diff --git a/snippets/js.code-snippets b/snippets/js.code-snippets index 6881d5c..405ce7c 100644 --- a/snippets/js.code-snippets +++ b/snippets/js.code-snippets @@ -647,22 +647,21 @@ "useFirstVisit": { "prefix": "useFirstVisit", "body": [ - "import { useState, useEffect } from 'react';", + "import { useState } from 'react';", "", "export const useFirstVisit = () => {", " const [isFirstVisit, setIsFirstVisit] = useState(false);", "", - " useEffect(() => {", - " const firstVisit = localStorage.getItem('firstVisit');", + " const firstVisit = localStorage.getItem('firstVisit');", "", - " if (firstVisit === null) {", - " localStorage.setItem('firstVisit', 'false');", - " setIsFirstVisit(true);", - " }", - " }, []);", + " if (firstVisit === null) {", + " localStorage.setItem('firstVisit', 'true');", + " setIsFirstVisit(true);", + " }", "", " return isFirstVisit;", - "};" + "};", + "" ], "description": "React hook to detect if it is the user's first visit" }, diff --git a/snippets/ts.code-snippets b/snippets/ts.code-snippets index 933b083..1288c0a 100644 --- a/snippets/ts.code-snippets +++ b/snippets/ts.code-snippets @@ -707,22 +707,21 @@ "useFirstVisit": { "prefix": "useFirstVisit", "body": [ - "import { useState, useEffect } from 'react';", + "import { useState } from 'react';", "", "export const useFirstVisit = (): boolean => {", " const [isFirstVisit, setIsFirstVisit] = useState(false);", "", - " useEffect(() => {", - " const firstVisit = localStorage.getItem('firstVisit');", + " const firstVisit = localStorage.getItem('firstVisit');", "", - " if (firstVisit === null) {", - " localStorage.setItem('firstVisit', 'false');", - " setIsFirstVisit(true);", - " }", - " }, []);", + " if (firstVisit === null) {", + " localStorage.setItem('firstVisit', 'true');", + " setIsFirstVisit(true);", + " }", "", " return isFirstVisit;", - "};" + "};", + "" ], "description": "React hook to detect if it is the user's first visit" },