@@ -59,24 +59,24 @@ Provider has different props you can use for configuration.
59
59
The most common BaseConfiguration properties used are:
60
60
61
61
- ``schema?: (RealmObjectConstructor<AnyRealmObject> | ObjectSchema)[]``
62
- Specifies all the object schemas in this Realm. Required when first creating a Realm.
63
- If omitted, the schema will be read from the existing Realm file.
62
+ Specifies all the object schemas in this Realm. Required when first creating a Realm.
63
+ If omitted, the schema will be read from the existing Realm file.
64
64
65
65
- ``sync?: SyncConfiguration``
66
- Configures a synced realm.
66
+ Configures a synced realm.
67
67
68
68
``RealmProvider`` has more props that define its behavior:
69
69
70
70
- ``fallback?: React.ComponentType<unknown> | React.ReactElement | null | undefined``
71
- The fallback component to render while the Realm is opening.
71
+ The fallback component to render while the Realm is opening.
72
72
73
73
- ``closeOnUnmount?: boolean``
74
- Default is ``true``. If set to ``false``, realm will not close when the
75
- component unmounts.
74
+ Default is ``true``. If set to ``false``, realm will not close when the
75
+ component unmounts.
76
76
77
77
- ``realmRef?: React.MutableRefObject<Realm | null>``
78
- A ref to the realm instance. This is useful if you need to access the realm
79
- instance outside of the scope of the realm.
78
+ A ref to the realm instance. This is useful if you need to access the realm
79
+ instance outside of the scope of the realm.
80
80
81
81
- ``children: React.ReactNode``
82
82
@@ -89,14 +89,14 @@ Provider has different props you can use for configuration.
89
89
The most common AppConfiguration property used is:
90
90
91
91
- ``id: string``
92
- Specifies the App ID.
92
+ Specifies the App ID.
93
93
94
94
.. tab:: UserProvider Props
95
95
:tabid: user-provider-props
96
96
97
97
- ``fallback?: React.ComponentType<unknown> | React.ReactElement | null | undefined``
98
- The fallback component to render if there is no authorized user. This can be
99
- used to render a log in screen or otherwise handle authentication.
98
+ The fallback component to render if there is no authorized user. This can be
99
+ used to render a log in screen or otherwise handle authentication.
100
100
101
101
Configure your Providers
102
102
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -105,38 +105,32 @@ This section details how to configure and expose a single realm using a ``RealmP
105
105
imported directly from ``@realm/react``. For information about using ``createRealmContext()``
106
106
to configure a realm or exposing more than one realm, refer to their respective sections below.
107
107
108
- If you are developing an app using sync, you will need to use all three Providers. If you are
109
- developing an app without sync, you only need to use ``RealmProvider``.
110
-
111
108
.. tabs::
112
109
113
110
.. tab:: Configure realm with sync
114
111
:tabid: configure-sync-realm
115
112
113
+ If you are developing an app using sync, you will need to use all three Providers.
114
+
116
115
By default, Realm syncs all data from the server before returning anything. If you want
117
116
to sync data in the background, read Configure a Synced Realm While Offline [link].
118
117
119
118
To configure a synced realm:
120
119
121
- # . Import ``RealmProvider``, ``AppProvider``, and ``UserProvider`` from ``@realm/react``.
120
+ 1 . Import ``RealmProvider``, ``AppProvider``, and ``UserProvider`` from ``@realm/react``.
122
121
123
- # . Configure ``AppProvider``.
124
- Pass your App ID string to the ``id`` prop of the ``AppProvider``.
122
+ 2 . Configure ``AppProvider``.
123
+ a. Pass your App ID string to the ``id`` prop of the ``AppProvider``.
125
124
126
- #. Configure ``UserProvider`` and nest it within ``AppProvider``.
127
-
128
- Pass a component that logs a user in into the ``fallback`` prop. The app renders this component if there is no authenticated user.
125
+ 3. Configure ``UserProvider`` and nest it within ``AppProvider``.
126
+ a. Pass a component that logs a user in into the ``fallback`` prop. The app renders this component if there is no authenticated user.
129
127
130
- #. Configure ``RealmProvider`` for sync and nest it within ``UserProvider``.
131
-
132
- Pass your object models to the ``schema`` prop. (link out)
133
-
134
- Pass your sync properties into the ``sync`` prop. Your sync properties are formatted like a json dictionary.
135
-
136
- Add other Configuration object properties as props to ``RealmProvider``.
137
-
138
- You must set up a sync subscription. The example below uses an initial subscription,
139
- but you can also set up subscriptions in ``RealmProvider`` child components.
128
+ 4. Configure ``RealmProvider`` for sync and nest it within ``UserProvider``.
129
+ a. Pass your object models to the ``schema`` prop. (link out)
130
+ b. Pass your sync properties into the ``sync`` prop. Your sync properties are formatted like a json dictionary.
131
+ c. Add other Configuration object properties as props to ``RealmProvider``.
132
+ d. You must set up a sync subscription. The example below uses an initial subscription,
133
+ but you can also set up subscriptions in ``RealmProvider`` child components.
140
134
141
135
.. include:: /includes/note-rn-multiple-app-clients-and-app-config-cache.rst
142
136
@@ -150,6 +144,8 @@ developing an app without sync, you only need to use ``RealmProvider``.
150
144
.. tab:: Configure realm without sync
151
145
:tabid: configure-non-sync-realm
152
146
147
+ If you are developing an app without sync, you only need to use ``RealmProvider``.
148
+
153
149
To configure a non-synced realm:
154
150
155
151
#. Import ``RealmProvider`` from ``@realm/react``.
@@ -164,8 +160,8 @@ developing an app without sync, you only need to use ``RealmProvider``.
164
160
[code example - unsynced]
165
161
166
162
167
- Working in your Providers
168
- -------------------------
163
+ Working with Providers using Hooks
164
+ ----------------------------------
169
165
170
166
To use the Provider's context in your app's components, you can use hooks [link].
171
167
0 commit comments