refactor: simplify parameter destructuring in loader functions across routes
This commit is contained in:
@@ -9,10 +9,9 @@ import type { Route } from './+types/_news.category.$code'
|
||||
|
||||
export const loader = async ({ params }: Route.LoaderArgs) => {
|
||||
const { data: categoriesData } = await getCategories()
|
||||
const categoryData = categoriesData.find(
|
||||
(category) => category.code === params.code,
|
||||
)
|
||||
const { data: newsData } = await getNews({ categories: [params.code] })
|
||||
const { code } = params
|
||||
const categoryData = categoriesData.find((category) => category.code === code)
|
||||
const { data: newsData } = await getNews({ categories: [code] })
|
||||
return { categoryData, newsData }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user