Skip to content

Commit

Permalink
fix: show like/dislike when loading place page (#578)
Browse files Browse the repository at this point in the history
* fix: show like/dislike when loading place page
  • Loading branch information
braianj authored Jan 9, 2025
1 parent 83ef397 commit 40a1b42
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/hooks/usePlaceFromParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import isUUID from "validator/lib/isUUID"
import Places from "../api/Places"
import toCanonicalPosition from "../utils/position/toCanonicalPosition"

export function usePlaceFromParams(params: URLSearchParams) {
export function usePlaceFromParams(
params: URLSearchParams,
deps: React.DependencyList = []
) {
return useAsyncMemo(
async () => {
if (params.get("id")) {
Expand Down Expand Up @@ -32,7 +35,7 @@ export function usePlaceFromParams(params: URLSearchParams) {

return null
},
[params],
[params, ...deps],
{ callWithTruthyDeps: true, initialValue: null }
)
}
4 changes: 3 additions & 1 deletion src/pages/place.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ export default function PlacePage() {
[location.search]
)

const [placeRetrived, placeRetrivedState] = usePlaceFromParams(params)
const [placeRetrived, placeRetrivedState] = usePlaceFromParams(params, [
account,
])

const placeMemo = useMemo(
() => (!placeRetrived ? [[]] : [[placeRetrived]]),
Expand Down

0 comments on commit 40a1b42

Please sign in to comment.