Nexca is admin panel that we build recently and this article I gonna explain each hook to understand them better for find the latest update you check them here .
The useFetch hook is used to fetch data such as posts, services, or sections from a specified URL. This hook takes one parameter, which is the URL from which to fetch the data.
const data = useFetch('/api/posts/');
The useGetSection hook is used to fetch data from a specific section. This hook is particularly useful for the client section. It takes three parameters:
You can also extract the loading state to display a skeleton while the posts are loading.
const { data, loading } = useGetSection('/api/posts/', 8, 2);
The useGetLatestPosts hook is used to fetch the latest posts on the site. This hook takes one parameter:
It is good practice to set the number of items you want to see using useState.
const [recentSize] = useState(5); const { posts } = useGetLatestPosts(recentSize);
The useCheckLogin hook is used exclusively for the admin to check if a user is logged in. It does not take any parameters and should only be called in the admin page or layout.
The useSinglePost hook is used to fetch a single post based on an ID parameter. It finds the matching post and displays it to the user. This hook is only used on the /Posts/[id] page.
const post = useSinglePost(); // To read data from the post{post.title}
The useReadText hook is used to read a given text using the browser's speech synthesis capability. It provides functionality to start and stop the reading process. This hook takes one parameter:
The hook maintains a state isSpeaking to indicate whether the text is currently being read. It returns three values:
import { useReadText } from './useReadText'; const ExampleComponent = () => { const { isSpeaking, handleReadText, handleStopReading } = useReadText('Hello, this is a sample text.'); return (); };
Live Demo
Username: admin
Password: a123b456@@
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3