The error occurs because react-hook-mousetrap
is exported as an ESM library. You can have Next.js transpile it using next-transpile-modules
in your next.config.js
.
const withTM = require('next-transpile-modules')(['react-hook-mousetrap']);
module.exports = withTM({ /* Your Next.js config */});
More Related Contents:
- Next.js context provider wrapping App component with page specific layout component giving undefined data
- The useState set method is not reflecting a change immediately
- React Hook Warnings for async function in useEffect: useEffect function must return a cleanup function or nothing
- Window is not defined in Next.js React app
- How can I use multiple refs for an array of elements with hooks?
- Invalid hook call. Hooks can only be called inside of the body of a function component
- Can I set state inside a useEffect hook
- How to call an async function inside a UseEffect() in React?
- Why is useState not triggering re-render?
- How to register event with useEffect hooks?
- Is there a generic way to set state in React Hooks? How to manage multiple states?
- React Function Components with hooks vs Class Components
- React hooks: accessing up-to-date state from within a callback
- React Hooks – What’s happening under the hood?
- useEffect does not listen for localStorage
- Determine which dependency array variable caused useEffect hook to fire
- React hooks: call component as function vs render as element
- React hooks useState setValue still rerender one more time when value is equal
- unable to deploy next js to azure
- Updating state to the same state directly in the component body
- Next.js: Error: React.Children.only expected to receive a single React element child
- Uncaught Invariant Violation: Rendered more hooks than during the previous render
- React Hook “useEffect” is called conditionally
- What are the differences when re-rendering after state was set with Hooks compared to the class-based approach?
- Performance penalty of creating handlers on every render with react-hooks
- Function inside functional component in React hooks – Performance
- how can I use top level “await” in typescript next.js
- You’re importing a component that needs useState. It only works in a Client Component, but none of its parents are marked with “use client”
- How to prevent Next.js from instantiating a singleton class/object multiple times?
- Why would we use useEffect without a dependency array?