Skip to content

Realm React v0.5.0

Compare
Choose a tag to compare
@github-actions github-actions released this 19 Jun 14:46
· 491 commits to main since this release
32d2e47

Enhancements

  • Add authentication hooks, useAuth and useEmailPasswordAuth
    Usage example

  • Allow useQuery to be passed a query function where sorted and filtered methods can be called (#5471) Thanks for the contribution @levipro!

    Example:

     const SomeComponent = () => {
         const user = useUser();
         const items = useQuery(Item,
             (res) => res.filtered(`owner_id == "${user?.id}"`).sorted('createdAt'),
             [user]
         );
     };
  • Create a default context so the RealmProvider, useQuery, useRealm, and useObject can be directly imported from @realm/react (#5292)

    Example:

     // These imports are now available without calling `createRealmContext`
     import {RealmProvider, useQuery} from '@realm/react'
     //...
     // Provider your schema models directly to the realm provider
     <RealmProvider schema={[Item]}>
     	<SomeComponent/>
     </RealmProvider>
    
     const SomeComponent = () => {
     	const items = useQuery(Item)
    
     	//...
     }

    NOTE: If your app is using multiple Realms, then you should continue using createRealmContext

Fixed

  • useUser is now typed to never returned null #4973
    Example:
     const user = useUser();
     // before
     console.log(user?.id); // Optional chaining required
     // now
     console.log(user.id); // No typing error
    

Compatibility

  • React Native >= v0.70.0
  • Atlas App Services.
  • Realm Studio v13.0.0.
  • File format: generates Realms with format v23 (reads and upgrades file format v5 or later for non-synced Realm, upgrades file format v10 or later for synced Realms).