Importing LinearGradient deprecation warning after upgrading to sdk 33

I upgraded an Expo project to SDK v33 this morning, following the instructions here. Now when I run my app I get a warning that the LinearGradient package is deprecated:

The following APIs have moved to separate packages and importing them from the "expo" package is deprecated: LinearGradient.

1. Add correct versions of these packages to your project using:

   expo install expo-linear-gradient

   If "install" is not recognized as an expo command, update your expo-cli installation.

2. Change your imports so they use specific packages instead of the "expo" package:

 - import { LinearGradient } from 'expo' -> import { LinearGradient } from 'expo-linear-gradient'

After some hunting around through my codebase, I discovered that I don’t import LinearGradient anywhere. I believe the warning is due to my use of linearGradientProps on the Button component from react-native-elements. I upgraded react-native-elements to v1.1.0 too, for what it’s worth.

Per their website, LinearGradient is automatically included with Expo, so I’m not sure if I should post an issue on their repo or on Expo’s. I am looking for guidance on that point, please.

I did try following the console message’s instructions to run expo install expo-linear-gradient, but that made no difference.

I was unable to reproduce this issue in a snack, but I did reproduce it in a repo that you can clone and run locally: GitHub - schellack/linearGradient: React native repo running Expo SDK v33 showing how using a LinearGradient on a Button component from the react-native-elements library causes a deprecation warning.

Same issue here

The following APIs have moved to separate packages and importing them from the "expo" package is deprecated: Constants.

1. Add correct versions of these packages to your project using:

   expo install expo-constants

   If "install" is not recognized as an expo command, update your expo-cli installation.

2. Change your imports so they use specific packages instead of the "expo" package:

 - import { Constants } from 'expo' -> import Constants from 'expo-constants'

Yes, I do import Constants but I was following migration guide and I’m sure I do it in the right way. In addition, even if I remove all imports to Constants, the problem doesn’t disappear. My console is completely full with these messages, I can’t see my debug messages.

It would be worth to raise an issue on GitHub.

see the writeup in this PR for more info: [expo] Export a limited set of globals based on usage by brentvatne · Pull Request #4470 · expo/expo · GitHub - basically what is happening is that some libraries are accessing Constants, LinearGradient and other things via the global.Expo object, which we had to add to work around metro not supporting conditional imports.

we’ll add LinearGradient to the export list as well for now, and once there is a better solution optional dependencies available (eg: Optional imports in Metro · Issue #120 · react-native-community/discussions-and-proposals · GitHub) then we can deprecate the global Expo object.

tl;dr: working on a fix for this warning now. it’s annoying to see, yeah, but it’s not going to cause any problems and we’ll have a solution soon.

2 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.