Getting this error trying to import useDimensions

i have this error trying to import useDimensions

241 |
242 | if (error instanceof InvalidPackageError) {
243 | throw new PackageResolutionError({
| ^
244 | packageError: error,
245 | originModulePath: from,
246 | targetModuleName: to,]

import { useDimensions } from “@react-native-community/hooks”;

export default function App() {
console.log(useDimensions());
return (

<View
style={{ width: “50%”, height: 100, backgroundColor: “dodgerblue” }}
>

);
}

Not a React Native developer, but:

  1. did you install the package?

    npm install @react-native-community/hooks

    or

    yarn add @react-native-community/hooks

  2. are you using React Native >= 0.59.0?

thanks i already solved it, i don’t know what the problem was but i restarted everything and it worked

1 Like