React higher order components for the deepstream.io server.
Provides the deepstream record to the component.
Properties passed to the wrapped component:
record
an object containing the record's propertiesonChange
a 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:
entries
an array with the entries held by that listaddEntry
a 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:
rpcResult
the 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} />
)