Socket
Book a DemoInstallSign in
Socket

react-bicycle

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-bicycle

React bindings for the bicycle data synchronisation library

latest
Source
npmnpm
Version
5.1.0
Version published
Maintainers
1
Created
Source

React Bicycle

React bindings for the bicycle data synchronisation library

Usage

For an full demo of a task list app see:

  • with ts-bicycle src/demo/ts-hooks and src/demo/ts-schema
  • without ts-bicycle src/demo/js-hooks and src/demo/js-schema

These demos are API compatible, so you can use either client with either backend.

import React from 'react';
import ReactDOM from 'react-dom';
import BicycleClient from 'bicycle/client';
import useQuery, {useClient, BicycleProvider} from 'react-bicycle';

function App() {
  const client = useClient();
  const q = useQuery({myField: true});

  // If the query result has not yet loaded, or has errored
  // render an appropriate placeholder.
  // `q` has properties to allow you to render your own custom
  // loading indicator or error message.
  if (!q.loaded) return r.render();
  
  // client.update('Root.setMyField', {value})

  return <div>My Field: <strong>{q.result.myField}</strong></div>;
}

const client = new BicycleClient();
ReactDOM.render(
  <BicycleProvider client={client}><AppContainer/></BicycleProvider>,
  document.getElementById('container'),
);

FAQs

Package last updated on 23 Feb 2019

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