Skip to content

Commit d21afd9

Browse files
Remove action function from data table story and rely solely on loader for data fetching
1 parent f2b051b commit d21afd9

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

apps/docs/src/remix-hook-form/data-table-router-form.stories.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { dataTableRouterParsers } from '@lambdacurry/forms/remix-hook-form/data-
33
import { DataTableColumnHeader } from '@lambdacurry/forms/ui/data-table/data-table-column-header';
44
import type { Meta, StoryObj } from '@storybook/react';
55
import type { ColumnDef } from '@tanstack/react-table';
6-
import { type ActionFunctionArgs, useLoaderData } from 'react-router';
6+
import { type LoaderFunctionArgs, useLoaderData } from 'react-router';
77
import { z } from 'zod';
88
import { withReactRouterStubDecorator } from '../lib/storybook/react-router-stub';
99

@@ -135,7 +135,8 @@ function DataTableRouterFormExample() {
135135
);
136136
}
137137

138-
const handleDataFetch = async ({ request }: ActionFunctionArgs) => {
138+
// Loader function to handle data fetching based on URL parameters
139+
const handleDataFetch = async ({ request }: LoaderFunctionArgs) => {
139140
// Add a small delay to simulate network latency
140141
await new Promise(resolve => setTimeout(resolve, 300));
141142

@@ -198,6 +199,7 @@ const handleDataFetch = async ({ request }: ActionFunctionArgs) => {
198199
// Log the data being returned for debugging
199200
console.log(`Returning ${paginatedData.length} items, page ${safePage}, total ${filteredData.length}`);
200201

202+
// Return the data response
201203
return {
202204
data: paginatedData,
203205
meta: {
@@ -222,7 +224,6 @@ const meta = {
222224
path: '/',
223225
Component: DataTableRouterFormExample,
224226
loader: handleDataFetch,
225-
action: handleDataFetch, // Add action to handle form submissions
226227
},
227228
],
228229
}),

0 commit comments

Comments
 (0)