Skip to content

Commit 0ffa29b

Browse files
committed
optional props example
1 parent e734188 commit 0ffa29b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

app/controllers/topics_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def index
1212
render inertia: {
1313
topics: topics,
1414
trending_topics: calculate_trending_topics(topics)
15+
# trending_topics: InertiaRails.optional { calculate_trending_topics(topics) }
1516
# trending_topics: InertiaRails.defer { calculate_trending_topics(topics) }
1617
}
1718
end

app/frontend/pages/topics/index.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1-
import { Head } from '@inertiajs/react'
1+
// import { useEffect } from 'react'
2+
import { Head /*, router, usePage */ } from '@inertiajs/react'
23
import AppLayout from '../../layouts/AppLayout'
34
import { Topic } from '../../types'
45
import TopicsTable from '../../components/TopicsTable'
56

67
function TopicsIndex({ topics, trending_topics }: { topics: Topic[], trending_topics: number[] }) {
8+
/*
9+
const {url} = usePage();
10+
11+
useEffect(() => {
12+
// router.reload({only: ['trending_topics']})
13+
14+
router.visit(url, {
15+
only: ['trending_topics'],
16+
preserveState: true,
17+
});
18+
}, [])
19+
*/
20+
721
return (
822
<AppLayout>
923
<Head title="Topics - Pups & Pourovers" />

0 commit comments

Comments
 (0)