Skip to content

Commit

Permalink
Finish feature/25
Browse files Browse the repository at this point in the history
  • Loading branch information
dlcastillop authored Jan 6, 2025
2 parents 73b9852 + 5ee6e4d commit b70e819
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
17 changes: 8 additions & 9 deletions snippets/js.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
17 changes: 8 additions & 9 deletions snippets/ts.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>(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"
},
Expand Down

0 comments on commit b70e819

Please sign in to comment.