From 7f205963be82c678171e9b926dcc48fc16418f49 Mon Sep 17 00:00:00 2001
From: Matt Brophy
Date: Mon, 9 Jan 2023 14:25:17 -0500
Subject: [PATCH 1/3] Update github New Issue workflow to mimic Remix
---
.github/ISSUE_TEMPLATE/bug_report.yml | 15 +-
.github/ISSUE_TEMPLATE/config.yml | 19 +-
.github/ISSUE_TEMPLATE/feature_request.yml | 32 --
examples/data-router/src/app.tsx | 388 ++++++++++++++++++--
examples/data-router/src/routes.tsx | 399 ---------------------
5 files changed, 381 insertions(+), 472 deletions(-)
delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml
delete mode 100644 examples/data-router/src/routes.tsx
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index c4892dfa85..1f53977ea9 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -11,18 +11,21 @@ body:
Do you need some help?
======================
- The issue tracker is meant for feature requests and bug reports only. This isn't the best place for
- support or usage questions. Questions here don't have as much visibility as they do elsewhere. Before
- you ask a question, here are some resources to get help first:
+ The issue tracker is meant for bug reports only. This isn't the best
+ place for support or usage questions. Questions here don't have as much
+ visibility as they do elsewhere. Before you ask a question, here are
+ some resources to get help first:
- Read the docs: https://reactrouter.com
- Check out the list of frequently asked questions: https://reactrouter.com/start/faq
- Explore examples: https://reactrouter.com/start/examples
- - Look for/ask questions on Stack Overflow: https://stackoverflow.com/questions/tagged/react-router
- Ask in chat: https://discord.gg/6RyV8n8yyM
+ - Look for/ask questions on Stack Overflow: https://stackoverflow.com/questions/tagged/react-router
+
+ ### Test Case Starters:
- ### Test Case Starter:
- https://stackblitz.com/github/remix-run/react-router/tree/main/examples/basic?file=src/App.tsx
+ * (Using ``)[https://stackblitz.com/github/remix-run/react-router/tree/main/examples/data-router?file=src/App.tsx]
+ * (Using ``)[https://stackblitz.com/github/remix-run/react-router/tree/main/examples/basic?file=src/App.tsx]
- type: input
attributes:
label: What version of React Router are you using?
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
index d1bc9ec6a6..30c6cfa323 100644
--- a/.github/ISSUE_TEMPLATE/config.yml
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -1,5 +1,20 @@
blank_issues_enabled: false
contact_links:
- - name: 🤔 Support/Usage Question
+ - name: 💡 Feature Request
+ url: https://github.com/remix-run/react-router/discussions/new?category=proposals
+ about:
+ If you've got an idea for a new feature in React Router, please open a new
+ Discussion with the `Proposals` label. We'll review the most popular
+ proposals on a regular basis. Read more about our Open Development process
+ [here](https://remix.run/blog/open-development).
+ - name: 🤔 Usage Question (Stack Overflow)
url: https://stackoverflow.com/questions/tagged/react-router
- about: This is a bug tracker, not a support system. For usage questions, please use Stack Overflow where there are a lot more people ready to help you out. Thanks!
+ about: Open a question in Stack Overflow with the react-router label
+ - name: 🤔 Usage Question (Github Discussions)
+ url: https://github.com/remix-run/remix/discussions/new?category=q-a
+ about: Open a Discussion in GitHub wih the `Q&A` label
+ - name: 💬 Remix Discord Channel
+ url: https://rmx.as/discord
+ about: Interact with other people using React Router and Remix 📀. There's
+ plenty of channels for general discussions as well as a threaded `#help`
+ channel in here where you can ask for help with you issue.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml
deleted file mode 100644
index 960c34af47..0000000000
--- a/.github/ISSUE_TEMPLATE/feature_request.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-name: 💡 Feature Request
-description: I want to add something to React Router.
-title: "[Feature]: "
-labels:
- - feature
-body:
- - type: markdown
- attributes:
- value: |
- Thank you for contributing!
-
- Do you need some help?
- ======================
- The issue tracker is meant for feature requests and bug reports only. This isn't the best place for
- support or usage questions. Questions here don't have as much visibility as they do elsewhere. Before
- you ask a question, here are some resources to get help first:
-
- - Read the docs: https://reactrouter.com
- - Check out the list of frequently asked questions: https://reactrouter.com/start/faq
- - Explore examples: https://reactrouter.com/start/examples
- - Look for/ask questions on Stack Overflow: https://stackoverflow.com/questions/tagged/react-router
- - Ask in chat: https://discord.gg/6RyV8n8yyM
- - type: textarea
- attributes:
- label: What is the new or updated feature that you are suggesting?
- validations:
- required: true
- - type: textarea
- attributes:
- label: Why should this feature be included?
- validations:
- required: true
diff --git a/examples/data-router/src/app.tsx b/examples/data-router/src/app.tsx
index 93c4f399c9..d6e9a89534 100644
--- a/examples/data-router/src/app.tsx
+++ b/examples/data-router/src/app.tsx
@@ -1,50 +1,35 @@
import React from "react";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router-dom";
import {
+ Await,
createBrowserRouter,
createRoutesFromElements,
+ defer,
+ Form,
+ Link,
+ Outlet,
Route,
RouterProvider,
+ useAsyncError,
+ useAsyncValue,
+ useFetcher,
+ useFetchers,
+ useLoaderData,
+ useNavigation,
+ useParams,
+ useRevalidator,
+ useRouteError,
} from "react-router-dom";
-import {
- Fallback,
- Layout,
- homeLoader,
- Home,
- deferredLoader,
- DeferredPage,
- deferredChildLoader,
- deferredChildAction,
- DeferredChild,
- todosAction,
- todosLoader,
- TodosList,
- TodosBoundary,
- todoLoader,
- Todo,
- sleep,
- AwaitPage,
-} from "./routes";
+import type { Todos } from "./todos";
+import { addTodo, deleteTodo, getTodos } from "./todos";
+
import "./index.css";
let router = createBrowserRouter(
createRoutesFromElements(
}>
} />
- }>
- }
- />
-
- } />
- sleep(3000)}
- element={
👋
}
- />
} />
+ }
+ />
)
);
@@ -65,3 +55,335 @@ if (import.meta.hot) {
export default function App() {
return } />;
}
+
+export function sleep(n: number = 500) {
+ return new Promise((r) => setTimeout(r, n));
+}
+
+export function Fallback() {
+ return
Performing initial data load
;
+}
+
+// Layout
+export function Layout() {
+ let navigation = useNavigation();
+ let revalidator = useRevalidator();
+ let fetchers = useFetchers();
+ let fetcherInProgress = fetchers.some((f) =>
+ ["loading", "submitting"].includes(f.state)
+ );
+ return (
+ <>
+
Data Router Example
+
+
+ This example demonstrates some of the core features of React Router
+ including nested <Route>s, <Outlet>s, <Link>s, and
+ using a "*" route (aka "splat route") to render a "not found" page when
+ someone visits an unrecognized URL.
+
+
+
+
+ {navigation.state !== "idle" &&
Navigation in progress...
}
+ {revalidator.state !== "idle" &&
Revalidation in progress...
}
+ {fetcherInProgress &&
Fetcher in progress...
}
+
+
+ Click on over to /todos and check out these
+ data loading APIs!
+
+
+ Or, checkout /deferred to see how to
+ separate critical and lazily loaded data in your loaders.
+
+
+ We've introduced some fake async-aspects of routing here, so Keep an eye
+ on the top-right hand corner to see when we're actively navigating.
+
+
+
+ >
+ );
+}
+
+// Home
+interface HomeLoaderData {
+ date: string;
+}
+
+export async function homeLoader(): Promise {
+ await sleep();
+ return {
+ date: new Date().toISOString(),
+ };
+}
+
+export function Home() {
+ let data = useLoaderData() as HomeLoaderData;
+ return (
+ <>
+
Home
+
Date from loader: {data.date}
+ >
+ );
+}
+
+// Todos
+export async function todosAction({ request }: ActionFunctionArgs) {
+ await sleep();
+
+ let formData = await request.formData();
+
+ // Deletion via fetcher
+ if (formData.get("action") === "delete") {
+ let id = formData.get("todoId");
+ if (typeof id === "string") {
+ deleteTodo(id);
+ return { ok: true };
+ }
+ }
+
+ // Addition via
}>
- {(data: string) =>
{data}
}
-
- );
-}
-
-function RenderAwaitedData() {
- let data = useAsyncValue() as string;
- return
{data}
;
-}
-
-function RenderAwaitedError() {
- let error = useAsyncError() as Error;
- return (
-
- );
-}
From 6265af85f0b509ddcd8e29ad2dc7b253959e7db1 Mon Sep 17 00:00:00 2001
From: Matt Brophy
Date: Mon, 9 Jan 2023 14:34:18 -0500
Subject: [PATCH 2/3] Proper discurd link
---
.github/ISSUE_TEMPLATE/bug_report.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index 1f53977ea9..75f66f3dcb 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -19,7 +19,7 @@ body:
- Read the docs: https://reactrouter.com
- Check out the list of frequently asked questions: https://reactrouter.com/start/faq
- Explore examples: https://reactrouter.com/start/examples
- - Ask in chat: https://discord.gg/6RyV8n8yyM
+ - Ask in chat: https://rmx.as/discord
- Look for/ask questions on Stack Overflow: https://stackoverflow.com/questions/tagged/react-router
### Test Case Starters:
From 16ff60af7ca272101c1215f0c4f4ad4cd65c7b21 Mon Sep 17 00:00:00 2001
From: Matt Brophy
Date: Mon, 9 Jan 2023 18:02:35 -0500
Subject: [PATCH 3/3] Add documentation issue template
---
.github/ISSUE_TEMPLATE/documentation_isse.yml | 21 +++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 .github/ISSUE_TEMPLATE/documentation_isse.yml
diff --git a/.github/ISSUE_TEMPLATE/documentation_isse.yml b/.github/ISSUE_TEMPLATE/documentation_isse.yml
new file mode 100644
index 0000000000..c9473a021e
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/documentation_isse.yml
@@ -0,0 +1,21 @@
+name: 📚 Documentation Issue
+description: Something is wrong with the React Router docs.
+title: "[Docs]: "
+labels:
+ - docs
+body:
+ - type: markdown
+ attributes:
+ value: |
+ Thank you for contributing!
+
+ For documentation updates - we would happily accept PRs, so feel free
+ to update and open a PR to the `main` branch. Otherwise let us know
+ in this issue what you felt was missing or incorrect.
+
+ - type: textarea
+ attributes:
+ label: Describe what's incorrect/missing in the documentation
+ description: A concise description of what you expected to see in the docs
+ validations:
+ required: true