Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Block Explorer UI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
Block Explorer UI
Commits
3f45976b
Commit
3f45976b
authored
4 months ago
by
Lukas
Committed by
mcfarhat
3 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Create custom hook to fetch post content data
parent
b41d4ef3
No related branches found
No related tags found
1 merge request
!483
Lbudginas/#385 single post page
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hooks/api/postPage/usePostContent.tsx
+23
-0
23 additions, 0 deletions
hooks/api/postPage/usePostContent.tsx
with
23 additions
and
0 deletions
hooks/api/postPage/usePostContent.tsx
0 → 100644
+
23
−
0
View file @
3f45976b
import
{
useQuery
}
from
"
@tanstack/react-query
"
;
import
fetchingService
from
"
@/services/FetchingService
"
;
const
usePostContent
=
(
accountName
:
string
,
permlink
:
string
)
=>
{
const
trimAccount
=
accountName
.
replace
(
"
@
"
,
""
);
const
{
data
,
isLoading
,
isError
}
=
useQuery
({
queryKey
:
[
"
blockSearch
"
,
trimAccount
,
permlink
],
queryFn
:
()
=>
fetchPostContent
(
trimAccount
,
permlink
),
refetchOnWindowFocus
:
false
,
});
const
fetchPostContent
=
async
(
accountName
:
string
,
permlink
:
string
)
=>
{
if
(
!
accountName
||
!
permlink
)
return
null
;
const
response
=
await
fetchingService
.
getContent
(
accountName
,
permlink
);
return
response
;
};
return
{
data
,
isLoading
,
isError
};
};
export
default
usePostContent
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment