Skip to content

Latest commit

 

History

History
83 lines (56 loc) · 2.86 KB

File metadata and controls

83 lines (56 loc) · 2.86 KB

@remix-run/server-runtime

1.7.1

Patch Changes

  • Properly locked the dependency on react-router-dom to version 6.3.0 (#4203)

1.7.0

Minor Changes

  • We've added a new type: SerializeFrom. This is used to infer the (#4013) JSON-serialized return type of loaders and actions.
  • MetaFunction type can now infer data and parentsData types from route loaders (#4022)

Patch Changes

  • Improved performance for data serialization at runtime (#3889)

1.6.8

Patch Changes

  • We've added type safety for load context. AppLoadContext is now an an interface mapping string to unknown, allowing users to extend it via module augmentation: (#1876)

    declare module "@remix-run/server-runtime" {
      interface AppLoadContext {
        // add custom properties here!
      }
    }

1.6.7

No significant changes to this package were made in this release. See the releases page on GitHub for an overview of all changes in v1.6.7.

1.6.6

No significant changes to this package were made in this release. See the releases page on GitHub for an overview of all changes in v1.6.6.

1.6.5

Patch Changes

  • We enhanced the type signatures of loader/action and useLoaderData/useActionData to make it possible to infer the data type from return type of its related server function.

    To enable this feature, you will need to use the LoaderArgs type from your Remix runtime package instead of typing the function directly:

    - import type { LoaderFunction } from "@remix-run/[runtime]";
    + import type { LoaderArgs } from "@remix-run/[runtime]";
    
    - export const loader: LoaderFunction = async (args) => {
    -   return json<LoaderData>(data);
    - }
    + export async function loader(args: LoaderArgs) {
    +   return json(data);
    + }

    Then you can infer the loader data by using typeof loader as the type variable in useLoaderData:

    - let data = useLoaderData() as LoaderData;
    + let data = useLoaderData<typeof loader>();

    The API above is exactly the same for your route action and useActionData via the ActionArgs type.

    With this change you no longer need to manually define a LoaderData type (huge time and typo saver!), and we serialize all values so that useLoaderData can't return types that are impossible over the network, such as Date objects or functions.

    See the discussions in #1254 and #3276 for more context.