This document provides explicit instructions for upgrading between major versions of this library.
- Replace your installation of
react-query@3.xwith@tanstack/react-query@4.x.
-
The
useAccountshook was removed. UseuseRestQuery('GET /v1/accounts', ...)instead. -
The
useAcceptInviteMutationhooks was removed. UseuseRestMutation('PATCH /v1/invitations/:inviteId', ...)instead.
react-native-mmkvis now a peer dependency.
-
TabBardefault styles have changed. Run the app post upgrade if you use theTabBarto examine updated styles and apply overrides as needed (note, default tabs do not useTabBar). -
The
TabBarstyles have been removed fromBrandConfigProviderand should now be provided as properties of theTabBarconfig on theDeveloperConfigfor each individual tab.
Before:
<BrandConfigProvider
styles={{
TabBar: {
labelActiveText0: {
backgroundColor: 'red',
},
labelInactive0Text: {
backgroundColor: 'yellow',
},
activeIndicator0View: {
backgroundColor: 'blue',
},
tabActive0View: {
backgroundColor: 'green',
},
tabInactive0View: {
backgroundColor: 'orange',
},
},
}}
/>After:
<DeveloperConfig
developerConfig={{
componentProps: {
TabBar: {
tabs: [
{
name: 'Tab',
component: SomeComponent,
styles: {
labelActiveText: {
backgroundColor: 'red',
},
labelInactiveText: {
backgroundColor: 'yellow',
},
activeIndicatorView: {
backgroundColor: 'blue',
},
tabActiveView: {
backgroundColor: 'green',
},
tabInactiveView: {
backgroundColor: 'orange',
},
},
},
],
},
},
}}
/>- The Svg Props for a tabs defined in the
DeveloperConfighave also been moved into a new styles property on each tab.
Before:
<DeveloperConfig
developerConfig={{
componentProps: {
TabBar: {
tabs: [
{
name: 'Tab',
component: SomeComponent,
svgProps: {
color: 'red',
},
svgPropsActive: {
color: 'yellow',
},
svgPropsInactive: {
color: 'blue',
},
},
],
},
},
}}
/>After:
<DeveloperConfig
developerConfig={{
componentProps: {
TabBar: {
tabs: [
{
name: 'Tab',
component: SomeComponent,
styles: {
svgProps: {
color: 'red',
},
svgPropsActive: {
color: 'yellow',
},
svgPropsInactive: {
color: 'blue',
},
},
},
],
},
},
}}
/>-
RootStackhas been removed. UseLoggedInStackin it's place instead. -
LoggedInProviderswill now render the login screen if the user is not logged in. -
If you are using a custom
BrandConfigProvideras a child ofRootProviders, you should move your locally-specific brand to theDeveloperConfigProviderinstead. Example:
// INSTEAD OF THIS:
const myBrand = {
/* ... */
};
const App = () => {
return (
<DeveloperConfigProvider
developerConfig={
{
/* ... */
}
}
>
<RootProviders authConfig={authConfig}>
<BrandConfigProvider {...brand}>
<RootStack />
</BrandConfigProvider>
</RootProviders>
</DeveloperConfigProvider>
);
};
// DO THIS:
const myBrand = {
/* ... */
};
const App = () => {
return (
<DeveloperConfigProvider
developerConfig={{
brand: myBrand,
}}
>
<RootProviders authConfig={authConfig}>
<LoggedInStack />
</RootProviders>
</DeveloperConfigProvider>
);
};-
ActiveAccountContextProviderandActiveProjectContextProviderwill now not render their children until the active account + project have been resolved. If there is no active account or project, theInviteRequiredscreen will be rendered in the place of children. -
The
useActiveProjecthook now returns non-optional data. You can simplify any conditional logic around those returned values.
RootProvidersnow requires anaccountprop. This should be set to the account id of the LifeOmic account you want your app to operate in.
<RootProviders
account="myaccount" // <-- add this
>
{/* ... */}
</RootProviders>useActiveAccountnow returns non-optional data. This can simplify any conditional logic around that data. For example:
const MyComponent = () => {
const { accountHeaders } = useActiveAccount();
const query = useQuery(
['my-query'],
() => client.get('/something', { headers: accountHeaders }),
{
enabled: !!accountHeaders,
},
);
};
// ^This can be simplified to:
const MyComponent = () => {
const { accountHeaders } = useActiveAccount();
const query = useQuery(['my-query'], () =>
client.get('/something', { headers: accountHeaders }),
);
};
// ^ No need to "wait" for the account to be resolved. It is always known.ActiveAccountContextProviderhas been renamed and refactored intoActiveAccountProvider.
- The clients returned from
useHttpClientanduseGraphQLClientnow automatically include theLifeOmic-Accountheader. You do not need to specify it manually. This also includes theuseRest****hooks. Example:
const MyComponent = () => {
const { httpClient } = useHttpClient();
const { accountHeaders } = useActiveAccount();
const query = useQuery(['my-query'], () =>
httpClient.get('/something', { headers: accountHeaders }),
);
};
// This^ can be simplified to:
const MyComponent = () => {
const { httpClient } = useHttpClient();
const query = useQuery(['my-query'], () => httpClient.get('/something'));
// the "accountHeaders" are included automatically.
};- To avoid including the
LifeOmic-Accountheader, you can specify an empty string for the header value, like so:'LifeOmic-Account': ''. When that empty string is provided, the header will be removed from the request.
-
The
InviteProvideris rendered in a different location, and does not render it's children while there is a pending invite. -
usePendingInviteno longer returns the "last accepted id". -
The
react-querycache is now cleared when an invite is accepted.
- The
react-queryquery key for theuseMe()data changed. The hook is now powered byuseRestQuery. If needing to interact with the cached data, use theuseRestCachehook.
-
The underlying query key for
useExchangeTokenchanged. -
The
clientIdparameter foruseExchangeTokenis no longer optional.