Skip to content

Commit dc7c2f1

Browse files
committed
switched configuration intro
1 parent f0ab34e commit dc7c2f1

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

source/frameworks/react/providers-hooks.txt

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,24 @@ Provider has different props you can use for configuration.
5959
The most common BaseConfiguration properties used are:
6060

6161
- ``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.
6464

6565
- ``sync?: SyncConfiguration``
66-
Configures a synced realm.
66+
Configures a synced realm.
6767

6868
``RealmProvider`` has more props that define its behavior:
6969

7070
- ``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.
7272

7373
- ``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.
7676

7777
- ``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.
8080

8181
- ``children: React.ReactNode``
8282

@@ -89,14 +89,14 @@ Provider has different props you can use for configuration.
8989
The most common AppConfiguration property used is:
9090

9191
- ``id: string``
92-
Specifies the App ID.
92+
Specifies the App ID.
9393

9494
.. tab:: UserProvider Props
9595
:tabid: user-provider-props
9696

9797
- ``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.
100100

101101
Configure your Providers
102102
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -105,38 +105,38 @@ This section details how to configure and expose a single realm using a ``RealmP
105105
imported directly from ``@realm/react``. For information about using ``createRealmContext()``
106106
to configure a realm or exposing more than one realm, refer to their respective sections below.
107107

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-
111108
.. tabs::
112109

113110
.. tab:: Configure realm with sync
114111
:tabid: configure-sync-realm
115112

113+
If you are developing an app using sync, you will need to use all three Providers.
114+
116115
By default, Realm syncs all data from the server before returning anything. If you want
117116
to sync data in the background, read Configure a Synced Realm While Offline [link].
118117

119118
To configure a synced realm:
120119

121-
#. Import ``RealmProvider``, ``AppProvider``, and ``UserProvider`` from ``@realm/react``.
122-
123-
#. Configure ``AppProvider``.
124-
Pass your App ID string to the ``id`` prop of the ``AppProvider``.
120+
1. Import ``RealmProvider``, ``AppProvider``, and ``UserProvider`` from ``@realm/react``.
125121

126-
#. Configure ``UserProvider`` and nest it within ``AppProvider``.
122+
2. Configure ``AppProvider``.
127123

128-
Pass a component that logs a user in into the ``fallback`` prop. The app renders this component if there is no authenticated user.
124+
a. Pass your App ID string to the ``id`` prop of the ``AppProvider``.
129125

130-
#. Configure ``RealmProvider`` for sync and nest it within ``UserProvider``.
126+
3. Configure ``UserProvider`` and nest it within ``AppProvider``.
127+
128+
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+
130+
4. Configure ``RealmProvider`` for sync and nest it within ``UserProvider``.
131131

132-
Pass your object models to the ``schema`` prop. (link out)
132+
a. Pass your object models to the ``schema`` prop. (link out)
133133

134-
Pass your sync properties into the ``sync`` prop. Your sync properties are formatted like a json dictionary.
134+
b. Pass your sync properties into the ``sync`` prop. Your sync properties are formatted like a json dictionary.
135135

136-
Add other Configuration object properties as props to ``RealmProvider``.
136+
c. Add other Configuration object properties as props to ``RealmProvider``.
137137

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.
138+
d. 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.
140140

141141
.. include:: /includes/note-rn-multiple-app-clients-and-app-config-cache.rst
142142

@@ -150,6 +150,8 @@ developing an app without sync, you only need to use ``RealmProvider``.
150150
.. tab:: Configure realm without sync
151151
:tabid: configure-non-sync-realm
152152

153+
If you are developing an app without sync, you only need to use ``RealmProvider``.
154+
153155
To configure a non-synced realm:
154156

155157
#. Import ``RealmProvider`` from ``@realm/react``.
@@ -164,8 +166,8 @@ developing an app without sync, you only need to use ``RealmProvider``.
164166
[code example - unsynced]
165167

166168

167-
Working in your Providers
168-
-------------------------
169+
Working with Providers using Hooks
170+
----------------------------------
169171

170172
To use the Provider's context in your app's components, you can use hooks [link].
171173

0 commit comments

Comments
 (0)