github sergiodxa/remix-utils v3.0.0

latest releases: v7.6.0, v7.5.0, v7.4.0...
2 years ago

What's Changed

json and useLoaderData/useActionData

The json response helper was updated to don't use type-fest anymore, and now in the init options (second argument) it can receive a replacer function to let you customize how values are transformed to string. Useful to support BigInt, Date, etc.

There are new useActionData and useLoaderData hooks, wrapping the Remix ones, which let you pass a reviver to parse back the objects you serialized with a replacer.

Both hooks lets you also pass a validator function, it receives the value from the loader/action and let you run a validation (e.g. using Zod) to check the value is correct. If you pass a validator, the return type of both hooks is inferred from the return type of the validator.

All response helpers use that json, also a new created response helper for a 201 status code.

Other React changes

The useRouteData now uses the match.id instead of the pathname or a custom ID.

The useRevalidate hook was replaced with useDataRefresh using useFetcher internally. It simulates the same API being discussed on the Remix repo.

The RevalidateLink was removed.

The deprecated usage of ClientOnly was removed.

The custom Outlet and useParentData hooks were removed.

Other Server changes

The verifyAuthenticityToken function now checks if the request body was already used and throw an error.

The bodyParser object was removed.

Full Changelog: v2.11.1...v3.0.0

Don't miss a new remix-utils release

NewReleases is sending notifications on new releases.