Skip to content

Commit d2938b6

Browse files
committed
switched configuration intro
1 parent f0ab34e commit d2938b6

File tree

1 file changed

+28
-32
lines changed

1 file changed

+28
-32
lines changed

source/frameworks/react/providers-hooks.txt

Lines changed: 28 additions & 32 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,32 @@ 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``.
120+
1. Import ``RealmProvider``, ``AppProvider``, and ``UserProvider`` from ``@realm/react``.
122121

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``.
125124

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.
129127

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.
140134

141135
.. include:: /includes/note-rn-multiple-app-clients-and-app-config-cache.rst
142136

@@ -150,6 +144,8 @@ developing an app without sync, you only need to use ``RealmProvider``.
150144
.. tab:: Configure realm without sync
151145
:tabid: configure-non-sync-realm
152146

147+
If you are developing an app without sync, you only need to use ``RealmProvider``.
148+
153149
To configure a non-synced realm:
154150

155151
#. Import ``RealmProvider`` from ``@realm/react``.
@@ -164,8 +160,8 @@ developing an app without sync, you only need to use ``RealmProvider``.
164160
[code example - unsynced]
165161

166162

167-
Working in your Providers
168-
-------------------------
163+
Working with Providers using Hooks
164+
----------------------------------
169165

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

0 commit comments

Comments
 (0)