From 74ed9a3ddc0a0678c6ae1c05a3171ba84688175d Mon Sep 17 00:00:00 2001 From: Alican Erdurmaz Date: Thu, 2 Jan 2025 10:05:49 +0300 Subject: [PATCH] feat(docs): upgrade live-preview examples to react router v7 (#6621) --- .../forms/custom-form-validation.md | 52 ++++++++++++------- .../_basic-usage-live-preview.md | 12 ++++- .../_filtering-live-preview.md | 12 ++++- .../_sorting-live-preview.md | 12 ++++- .../use-list/_basic-usage-live-preview.md | 12 ++++- .../hooks/use-list/_filtering-live-preview.md | 12 ++++- .../use-list/_pagination-live-preview.md | 12 ++++- .../hooks/use-list/_sorting-live-preview.md | 12 ++++- .../use-many/_basic-usage-live-preview.md | 14 +++-- .../use-one/_basic-usage-live-preview.md | 12 ++++- .../use-select/_basic-usage-live-preview.md | 20 ++++--- .../use-select/_default-value-live-preview.md | 22 +++++--- .../use-select/_on-search-live-preview.md | 20 ++++--- .../hooks/use-select/_sort-live-preview.md | 20 ++++--- .../use-show/_basic-usage-live-preview.md | 17 ++++-- .../_partial-basic-usage-live-preview.md | 12 ++++- .../_partial-filtering-live-preview.md | 12 ++++- .../_partial-pagination-live-preview.md | 12 ++++- .../_partial-relational-data-live-preview.md | 10 +++- .../_partial-sorting-live-preview.md | 12 ++++- .../docs/data/packages/supabase/index.md | 30 +++++++---- 21 files changed, 264 insertions(+), 85 deletions(-) diff --git a/documentation/docs/advanced-tutorials/forms/custom-form-validation.md b/documentation/docs/advanced-tutorials/forms/custom-form-validation.md index afa86aa784c8..10784e8c72cd 100644 --- a/documentation/docs/advanced-tutorials/forms/custom-form-validation.md +++ b/documentation/docs/advanced-tutorials/forms/custom-form-validation.md @@ -40,6 +40,8 @@ Now let's prepare a rule that checks if the titles of the posts are unique. We h ``` ```tsx live hideCode url=http://localhost:3000/posts/create +setInitialRoutes(["/posts/create"]); + // visible-block-start import { useForm, Create, CreateButton } from "@refinedev/antd"; import { Form, Input } from "antd"; @@ -61,10 +63,14 @@ interface PostUniqueCheckRequestQuery { // highlight-end const PostCreate: React.FC = () => { - const { formProps, saveButtonProps } = useForm(); + const { formProps, saveButtonProps } = useForm({ + defaultFormValues: { + title: "Test", + }, + }); // highlight-next-line - const [title, setTitle] = useState(""); + const [title, setTitle] = useState("Test"); // highlight-start const apiUrl = useApiUrl(); @@ -100,7 +106,8 @@ const PostCreate: React.FC = () => { }, { validator: async (_, value) => { - if (!value) return; + if (!value) + return Promise.reject(new Error("Please enter a title")); const { data } = await refetch(); if (data && data.data.isAvailable) { return Promise.resolve(); @@ -124,21 +131,30 @@ const PostCreate: React.FC = () => { // visible-block-end render( - ( -
-

This page is empty.

- -
- ), - create: PostCreate, - }, - ]} - />, + + + + +

This page is empty.

+ + + } + /> + } /> +
+
+
, ); ``` diff --git a/documentation/docs/data/hooks/use-infinite-list/_basic-usage-live-preview.md b/documentation/docs/data/hooks/use-infinite-list/_basic-usage-live-preview.md index 44deafb27c59..cd3e93f38546 100644 --- a/documentation/docs/data/hooks/use-infinite-list/_basic-usage-live-preview.md +++ b/documentation/docs/data/hooks/use-infinite-list/_basic-usage-live-preview.md @@ -55,10 +55,18 @@ setRefineProps({ resources: [ { name: "posts", - list: PostList, + list: "/posts", }, ], }); -render(); +render( + + + + } /> + + + , +); ``` diff --git a/documentation/docs/data/hooks/use-infinite-list/_filtering-live-preview.md b/documentation/docs/data/hooks/use-infinite-list/_filtering-live-preview.md index 6bf5673ef316..0cfb20b27f3a 100644 --- a/documentation/docs/data/hooks/use-infinite-list/_filtering-live-preview.md +++ b/documentation/docs/data/hooks/use-infinite-list/_filtering-live-preview.md @@ -88,10 +88,18 @@ setRefineProps({ resources: [ { name: "products", - list: ProductList, + list: "/products", }, ], }); -render(); +render( + + + + } /> + + + , +); ``` diff --git a/documentation/docs/data/hooks/use-infinite-list/_sorting-live-preview.md b/documentation/docs/data/hooks/use-infinite-list/_sorting-live-preview.md index 0a20b7aa8f60..90b41f739131 100644 --- a/documentation/docs/data/hooks/use-infinite-list/_sorting-live-preview.md +++ b/documentation/docs/data/hooks/use-infinite-list/_sorting-live-preview.md @@ -83,10 +83,18 @@ setRefineProps({ resources: [ { name: "products", - list: ProductList, + list: "/products", }, ], }); -render(); +render( + + + + } /> + + + , +); ``` diff --git a/documentation/docs/data/hooks/use-list/_basic-usage-live-preview.md b/documentation/docs/data/hooks/use-list/_basic-usage-live-preview.md index 11d9d9b5f593..a03ba9348486 100644 --- a/documentation/docs/data/hooks/use-list/_basic-usage-live-preview.md +++ b/documentation/docs/data/hooks/use-list/_basic-usage-live-preview.md @@ -51,10 +51,18 @@ setRefineProps({ resources: [ { name: "products", - list: ProductList, + list: "/products", }, ], }); -render(); +render( + + + + } /> + + + , +); ``` diff --git a/documentation/docs/data/hooks/use-list/_filtering-live-preview.md b/documentation/docs/data/hooks/use-list/_filtering-live-preview.md index 25a432bf90f9..f9eedc82007e 100644 --- a/documentation/docs/data/hooks/use-list/_filtering-live-preview.md +++ b/documentation/docs/data/hooks/use-list/_filtering-live-preview.md @@ -77,10 +77,18 @@ setRefineProps({ resources: [ { name: "products", - list: ProductList, + list: "/products", }, ], }); -render(); +render( + + + + } /> + + + , +); ``` diff --git a/documentation/docs/data/hooks/use-list/_pagination-live-preview.md b/documentation/docs/data/hooks/use-list/_pagination-live-preview.md index 75cd9d8ba8ad..6f16bc3c09b2 100644 --- a/documentation/docs/data/hooks/use-list/_pagination-live-preview.md +++ b/documentation/docs/data/hooks/use-list/_pagination-live-preview.md @@ -81,10 +81,18 @@ setRefineProps({ resources: [ { name: "products", - list: ProductList, + list: "/products", }, ], }); -render(); +render( + + + + } /> + + + , +); ``` diff --git a/documentation/docs/data/hooks/use-list/_sorting-live-preview.md b/documentation/docs/data/hooks/use-list/_sorting-live-preview.md index 963a8cc1ea72..40f1c8f3fd22 100644 --- a/documentation/docs/data/hooks/use-list/_sorting-live-preview.md +++ b/documentation/docs/data/hooks/use-list/_sorting-live-preview.md @@ -73,10 +73,18 @@ setRefineProps({ resources: [ { name: "products", - list: ProductList, + list: "/products", }, ], }); -render(); +render( + + + + } /> + + + , +); ``` diff --git a/documentation/docs/data/hooks/use-many/_basic-usage-live-preview.md b/documentation/docs/data/hooks/use-many/_basic-usage-live-preview.md index 6c1bafdc658c..0bdf52f24c64 100644 --- a/documentation/docs/data/hooks/use-many/_basic-usage-live-preview.md +++ b/documentation/docs/data/hooks/use-many/_basic-usage-live-preview.md @@ -54,7 +54,7 @@ const ProductList: React.FC = () => {