React higher order components for the deepstream.io server.
Provides the deepstream record to the component.
Properties passed to the wrapped component:
recordan object containing the record's propertiesonChangea callback that can be called when the record has changed
import React from 'react';
import { withRecord } from 'deepstream.io-react-hoc';
const Component = (props) => (
<div>
{JSON.serialize(props.record)}
</div>
);
const ConnectedComponent = withRecord(Component, 'record-name');
//use it:
(
<ConnectedComponent ds={dsClient} />
)Provides the deepstream list entries to the component.
Properties passed to the wrapped component:
entriesan array with the entries held by that listaddEntrya callback that can be called to add an entry to the list
import React from 'react';
import { withList } from 'deepstream.io-react-hoc';
const Component = (props) => (
<div>
{props.entries.map(entry => (<div>{entry}</div>)}
</div>
);
const ConnectedComponent = withList(Component, 'list-name');
//use it:
(
<ConnectedComponent ds={dsClient} />
)Calls the deepstream RPC method.
Properties passed to the wrapped component:
rpcResultthe result returned by the deepstream server
import React from 'react';
import { withRPC } from 'deepstream.io-react-hoc';
const Component = (props) => (
<div>
{JSON.stringify(props.rpcResult)}
</div>
);
const ConnectedComponent = withRPC(Component, 'rpcName', rpcOptionalArgs);
//use it:
(
<ConnectedComponent ds={dsClient} />
)