#route.useSomething() and eslint(react-hooks/rules-of-hooks)

5 messages · Page 1 of 1 (latest)

spiral otter
#

is it ok to do this:

const route = new Route({ /* etc */ });
const { useLoaderData } = route;

const Component = () => {
  const data = useLoaderData();
}

instead of this?

const route = new Route({ /* etc */ });

const Component = () => {
  const data = route.useLoaderData();
}

(same question for other route.useSomething hooks). the latter option is what i'm seeing in the docs, but you'll miss out on rule-of-hooks eslint warnings if you do it that way. looking at the source code, the former option should have the same behaviour right now, but I want to avoid any unexpected breaking changes if the API isn't supposed to be used this way 😅

#

route.useSomething() and eslint(react-hooks/rules-of-hooks)

fossil sentinel
#

It might be okay

#

Try out

#

If you get this is undefined, then it’s not okay.