Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't find variable: Dimensions

Tags:

react-native

When I try to use:

const {width, height} = Dimensions.get('window');

On a react native component, I get a weird error never seen before:

Can't find variable: Dimensions

screenshot of the error

Have someone face this issue before?

"dependencies": {
"expo": "^22.0.0",
"react": "16.0.0-beta.5",
"react-native": "https://github.com/expo/react-native/archive/sdk-22.0.2.tar.gz"

},

like image 986
davthecoder Avatar asked Nov 05 '17 12:11

davthecoder


1 Answers

Fix it... my mistake, I should import from react-native Dimensions.

import {Dimensions} from 'react-native';
like image 151
davthecoder Avatar answered Nov 13 '22 06:11

davthecoder