Skip to content

Conversation

@brophdawg11
Copy link
Contributor

Merging the feature branch for https://remix.run/blog/remixing-react-router

  • Adds a new @remix-run/router package (with included history APIs)
  • Adds data loading APIs to react-router via DataMemoryRouter and associated hooks
    • useActionData
    • useLoaderData
    • useMatches
    • useNavigation
    • useRevalidator
    • useRouteError
    • useRouteLoaderData
  • Adds data loading APIs to react-router-dom via DataBrowserRouter/DataHashRouter, plus a few additional components/hooks on top of the above
    • <Form>
    • <ScrollRestoration>
    • useFetcher/useFetchers
    • useSubmit

brophdawg11 and others added 30 commits April 12, 2022 16:25
* feat: add initial empty history package

* feat: add createMemoryHistory + tests

* chore: add rollup buld for history

* chore: change state type from unknown -> any

* feat: Change listen interface to be pop only

* chore: fix lint warning

* Add history package to yarn workspace

* chore: Address PR feedback
Additional notes:
 - adds unique route id generation to react-router
 - enhances test harness to manage at navigation level
 - combines error/catch into a single exception
This one was tricky:
 - react-router-native used to find the type for URLSearchParams from @types/react-native
 - The new history work added @types/jsdom
 - react-router-native now finds that URLSearchParams before the @types/react-native one
 - the jsdom one imports from the internal built-in TS DOM lib
 - but it does not include the DOM.Iterable values such as keys

See: microsoft/TypeScript#38139
 - loader/action
 - useLoaderData/useActionData/useTransition
 - exceptionElement/useRouteException
 - fallbackElement

export function useFormAction(action = "."): string {
let routeContext = React.useContext(UNSAFE_RouteContext);
invariant(routeContext, "useLoaderData must be used inside a RouteContext");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
invariant(routeContext, "useLoaderData must be used inside a RouteContext");
invariant(routeContext, "useFormAction must be used inside a RouteContext");

Drive by comment while looking at the new goodies 🚗

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! We've rebased this branch so I fixed this over in the new branch 👍

@brophdawg11
Copy link
Contributor Author

Closing to work off the newly rebased branch

@MichaelDeBoey MichaelDeBoey deleted the feat/remixing-router branch November 17, 2022 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants