You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Methods for prefetching data on server side rendering are available too. When data is prefetched in server side, the connect function will pass the `value` property calculated on server side to the components directly. It will not modify the `loading` property until the first load on client side is finished (At first client-side load, the resource will not be considered as `loading` to maintain the server-side value in the component until it finish loading).
183
183
184
+
> __It is important to define custom an unique "uuids" for your mercury sources when are going to be read on server side. Otherwise, the `readServerSide` method will throw an error if detects duplicated "ids".__
185
+
184
186
### Server side data methods and components
185
187
186
-
*`addServerSideData(source)`
188
+
*`readOnServerSide(source)`
189
+
* Alias - `addServerSideData`
187
190
* Arguments
188
-
* source - `<Object> or <Array> of <Objects>` Mercury source or sources that should be read when `readServerSideData` method is executed. Can be Mercury origins or selectors of any type, queried or not.
189
-
*`readServerSideData([source])`
191
+
* source - `<Object> or <Array> of <Objects>` Mercury source or sources that should be read when `readServerSide` method is executed. Can be Mercury origins or selectors of any type, queried or not.
192
+
*`readServerSide([source])`
193
+
* Alias - `readServerSideData`
190
194
* Arguments
191
-
* source - `<Object> or <Array> of <Objects>` Mercury source or sources that should be read when `readServerSideData` method is executed. Can be Mercury origins or selectors of any type, queried or not.
195
+
* source - `<Object> or <Array> of <Objects>` Mercury source or sources. Will be added to be read with the `readOnServerSide` method.
192
196
* Returns
193
-
* `<Object>` This method is asynchronous, and returns an object containing all server side data ready to be set on the `<ServerSideData>` context component.
194
-
*`<ServerSideData data={data} clientSide={true}><App/></ServerSideData>` Component that sets the result of the `readServerSideData` method in a context to make it available from all mercury connected children components.
197
+
* `<Object>` This method is asynchronous, and, when resolved, it returns an object containing all server side data ready to be set on the `<ServerSideData>` context component.
198
+
*`<ServerSideData data={data} clientSide={true}><App/></ServerSideData>` Component that sets the result of the `readServerSide` method in a context to make it available from all mercury connected children components.
195
199
* Props
196
-
* data - `<Object>` Object containing the result of the `readServerSideData` method.
200
+
* data - `<Object>` Object containing the result of the `readServerSide` method.
197
201
* clientSide - `<Boolean>` If false, the connect method will not dispatch automatically the read method of the sources marked as "server-side", so, for example, api requests will not be repeated on client side, and data retrieved in server side will be always passed to connected components.
198
202
199
203
### Example of server side prefecth implementation in a Next project:
@@ -202,10 +206,10 @@ In the next example, the data of the "myDataSource" mercury source will be fetch
0 commit comments