0.5.2 • Published 11 days ago

gongo-client-react v0.5.2

Weekly downloads
65
License
MIT
Repository
github
Last release
11 days ago

gongo-client-react

React hooks for gongo-client

Copyright(c) 2020 by Gadi Cohen dragon@wastelands.net. MIT licensed.

Project

Main project page https://github.com/gongojs/project

Quickstart

import React from 'react';
import { useGongoLive } from 'gongo-client-react';

function App() {
  // That's it.  The component will update on any relevant change.
  const data = useGongoLive( () => db.collection('test').find() );

  return (
    <ol>
      { data.map(row => <li><code>{JSON.strinigfy(row)}</code></li> }      
    </ol>
  );
}

Hooks

useGongoLive( funcThatReturnsACursor )

LiveQuery on a result set, returns an array.

Example:

const data = useGongoLive( db => db.collection('test').find() );

useGongoOne( funcThatReturnsACursor )

LiveQuery for a single result.

Example:

const user = useGongoOne( db => db.collection('users').find({ _id: userId }) );

useGongoUserId()

LiveQuery on current userId... non-null if user is logged in.

// const opts = {
//   db: force a specific database
// };
const userId = useGongoUserId(/* opts */);
0.5.2

11 days ago

0.5.1

11 days ago

0.5.0

8 months ago

0.4.0

8 months ago

0.3.1

8 months ago

0.3.0

9 months ago

0.2.3

11 months ago

0.2.2

11 months ago

0.2.4

10 months ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago

0.0.3

2 years ago

0.0.2

3 years ago

0.0.1

3 years ago