Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gongo-client-react

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gongo-client-react

React hooks for GongoJS gongo-client

  • 0.5.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-76.19%
Maintainers
1
Weekly downloads
 
Created
Source

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 */);

Keywords

FAQs

Package last updated on 21 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc