new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

React Router · API · all subjects

hooks: navigation & data

6 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

useFetcher hook basic usage

useFetcher is a hook from react-router that returns an object containing a Form component and data property. The Form component submits data to the route action without causing a navigation. The data property contains the response from the action.

Accessing fetcher data in component

The response data from an action is accessed through the data property of the fetcher object returned by useFetcher. For example, fetcher.data?.errors retrieves the errors object returned from the action.

useLoaderData hook retrieves loader data

The useLoaderData hook is imported from react-router and called within a route component to access data returned by the route's loader. For example: import { useLoaderData } from "react-router"; function MyRoute() { const { records } = useLoaderData(); return <div>{records.length}</div>; }

useNavigation hook provides network state

The useNavigation hook gives you access to navigation.state, navigation.formData, navigation.location, and other network-related state information.

useFetcher hook for interaction state

The useFetcher hook facilitates interaction with fetcher.state, fetcher.formData, fetcher.data and other fetcher-related state without triggering navigation.

useNavigation formAction property

The useNavigation hook provides a formAction property that contains the action route being submitted. Use it to determine if a specific form is submitting: `const isSubmitting = navigation.formAction === "/signup";`

Give your agent this brain