Skip to content

Commit c9de1e5

Browse files
committed
added configuration code examples
1 parent dc7c2f1 commit c9de1e5

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

source/frameworks/react/providers-hooks.txt

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

6161
- ``schema?: (RealmObjectConstructor<AnyRealmObject> | ObjectSchema)[]``
62+
6263
Specifies all the object schemas in this Realm. Required when first creating a Realm.
6364
If omitted, the schema will be read from the existing Realm file.
6465

6566
- ``sync?: SyncConfiguration``
67+
6668
Configures a synced realm.
6769

6870
``RealmProvider`` has more props that define its behavior:
6971

7072
- ``fallback?: React.ComponentType<unknown> | React.ReactElement | null | undefined``
73+
7174
The fallback component to render while the Realm is opening.
7275

7376
- ``closeOnUnmount?: boolean``
77+
7478
Default is ``true``. If set to ``false``, realm will not close when the
7579
component unmounts.
7680

7781
- ``realmRef?: React.MutableRefObject<Realm | null>``
82+
7883
A ref to the realm instance. This is useful if you need to access the realm
7984
instance outside of the scope of the realm.
8085

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

9196
- ``id: string``
97+
9298
Specifies the App ID.
9399

94100
.. tab:: UserProvider Props
95101
:tabid: user-provider-props
96102

97103
- ``fallback?: React.ComponentType<unknown> | React.ReactElement | null | undefined``
104+
98105
The fallback component to render if there is no authorized user. This can be
99106
used to render a log in screen or otherwise handle authentication.
100107

@@ -145,7 +152,8 @@ to configure a realm or exposing more than one realm, refer to their respective
145152
You *must* nest the Providers and app components as shown below to ensure each component
146153
has access to its required context:
147154

148-
[Code example here]
155+
.. literalinclude:: /examples/generated/react-native/ts/configure-realm-sync.test.snippet.configure-realm-sync-full.tsx
156+
:language: javascript
149157

150158
.. tab:: Configure realm without sync
151159
:tabid: configure-non-sync-realm
@@ -163,7 +171,8 @@ to configure a realm or exposing more than one realm, refer to their respective
163171
Once your ``RealmProvider`` has been configured, nest your app components within it to
164172
give them access to the realm opened.
165173

166-
[code example - unsynced]
174+
.. literalinclude:: /examples/generated/react-native/ts/configure-realm-local.test.snippet.configure-realm.tsx
175+
:language: typescript
167176

168177

169178
Working with Providers using Hooks

0 commit comments

Comments
 (0)