This document provides explicit instructions for upgrading between major versions of this library.
- Replace your installation of
react-query@3.x
with@tanstack/react-query@4.x
.
-
The
useAccounts
hook was removed. UseuseRestQuery('GET /v1/accounts', ...)
instead. -
The
useAcceptInviteMutation
hooks was removed. UseuseRestMutation('PATCH /v1/invitations/:inviteId', ...)
instead.
react-native-mmkv
is now a peer dependency.
-
TabBar
default styles have changed. Run the app post upgrade if you use theTabBar
to examine updated styles and apply overrides as needed (note, default tabs do not useTabBar
). -
The
TabBar
styles have been removed fromBrandConfigProvider
and should now be provided as properties of theTabBar
config on theDeveloperConfig
for 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
DeveloperConfig
have 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',
},
},
},
],
},
},
}}
/>
-
RootStack
has been removed. UseLoggedInStack
in it's place instead. -
LoggedInProviders
will now render the login screen if the user is not logged in. -
If you are using a custom
BrandConfigProvider
as a child ofRootProviders
, you should move your locally-specific brand to theDeveloperConfigProvider
instead. 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>
);
};
-
ActiveAccountContextProvider
andActiveProjectContextProvider
will now not render their children until the active account + project have been resolved. If there is no active account or project, theInviteRequired
screen will be rendered in the place of children. -
The
useActiveProject
hook now returns non-optional data. You can simplify any conditional logic around those returned values.
RootProviders
now requires anaccount
prop. 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>
useActiveAccount
now 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.
ActiveAccountContextProvider
has been renamed and refactored intoActiveAccountProvider
.
- The clients returned from
useHttpClient
anduseGraphQLClient
now automatically include theLifeOmic-Account
header. 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-Account
header, 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
InviteProvider
is rendered in a different location, and does not render it's children while there is a pending invite. -
usePendingInvite
no longer returns the "last accepted id". -
The
react-query
cache is now cleared when an invite is accepted.
- The
react-query
query key for theuseMe()
data changed. The hook is now powered byuseRestQuery
. If needing to interact with the cached data, use theuseRestCache
hook.
-
The underlying query key for
useExchangeToken
changed. -
The
clientId
parameter foruseExchangeToken
is no longer optional.