Catalog npm
Back to packageRELEASE DETAILS

1.0.0

npm

3box-react-hooks

React hooks for 3box integration

3boxboxhooksprofilereactspace
Published14 Apr 2019
Direct dependencies11
Transitive dependenciesNot calculated

README

Current package documentation

3box-react-hooks

React hooks wrapping 3box API

Changelog

2.0.0 has a new API that is more in line with the 3box API. The new version also enables more lightweight builds with 3box-react-hooks/dist/api.

Installation

npm i -S 3box-react-hooks

Api

FunctionArgumentsReturnCorresponds to
useProfileaddress[, opts]profileBox.getProfile
usePublicSpaceaddress, space name[, opts]spaceBox.getSpace
useBoxaddress, provider[, opts]boxBox.openBox
useSpacespace name, box[, opts]spacebox.openSpace
useDelayedBoxaddress, provider[, opts][box, open]-
useDelayedSpacespace name, box[, opts][space, open]-

Delayed box and space

Delayed hooks can be used to postpone authentication. For example if a box should be opened when the user presses an authentication button. The return value from the hooks contains box/space which is null until authenticated and open which is a function that opens the box/space.

If the box and spaces are supposed to be opened at the same time, only the box needs to be delayed since the space waits for box to not be null before opening. There's an example below.

Optimize build for read-only operations

useProfile and usePublicSpace can be used by importing 3box-react-hooks/dist/api for a more lightweight build.

Example

import { useProfile, useBox, useSpace } from '3box-react-hooks';

const MyComponent = (props) => {
  const address = '0x88E146E0fd0F5AaCbc4f94365dF9f599A90139F1';
  const profile = useProfile(address);
  const box = useBox(address, window.ethereum);
  const space = useSpace('exampleSpace', box);

  const email = await box.private.get('email');
  const spaceValue = await space.private.get('key');

  return (
    <>
      <div>{profile.emoji}</div>
      <div>{email}</div>
      <div>{spaceValue}</div>
    </>
  );
}

Delayed box and space

import { useDelayedBox, useSpace } from '3box-react-hooks';

const MyComponent = (props) => {
  const address = '0x88E146E0fd0F5AaCbc4f94365dF9f599A90139F1';
  const [box, open] = useDelayedBox(address, window.ethereum);
  const space = useSpace('exampleSpace', box);

  const email = await box.private.get('email');
  const spaceValue = await space.private.get('key');

  return (
    <>
      <div>{email}</div>
      <div>{spaceValue}</div>
      <button onClick={open}>Authenticate</button>
    </>
  );
}

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 12

Native requirements
11 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
3box
Environment
{
  "local_name": "3box",
  "alias": false,
  "peer_metadata": null
}
^1.7.0development
@babel/core
Environment
{
  "local_name": "@babel/core",
  "alias": false,
  "peer_metadata": null
}
^7.4.3development
@babel/preset-env
Environment
{
  "local_name": "@babel/preset-env",
  "alias": false,
  "peer_metadata": null
}
^7.4.3development
@babel/preset-react
Environment
{
  "local_name": "@babel/preset-react",
  "alias": false,
  "peer_metadata": null
}
^7.0.0development
babel-loader
Environment
{
  "local_name": "babel-loader",
  "alias": false,
  "peer_metadata": null
}
^8.0.5development
babel-runtime
Environment
{
  "local_name": "babel-runtime",
  "alias": false,
  "peer_metadata": null
}
^6.26.0development
nacl-did
Environment
{
  "local_name": "nacl-did",
  "alias": false,
  "peer_metadata": null
}
^0.4.0development
react
Environment
{
  "local_name": "react",
  "alias": false,
  "peer_metadata": null
}
^16.8.6development
react-dom
Environment
{
  "local_name": "react-dom",
  "alias": false,
  "peer_metadata": null
}
^16.8.6development
webpack
Environment
{
  "local_name": "webpack",
  "alias": false,
  "peer_metadata": null
}
^4.30.0development
webpack-cli
Environment
{
  "local_name": "webpack-cli",
  "alias": false,
  "peer_metadata": null
}
^3.3.0development
react
Environment
{
  "local_name": "react",
  "alias": false,
  "peer_metadata": null
}
>= 16.8.6peer

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-fLLS/GSJ6Ip1055oE3uwe1o5aKIHEPHgXokNu7HvkkVA3+H9kQBo18JYOWowb9TjSUpEaEOuvKgD20wkCFgx5A==",
  "shasum": "47699379599facc0e80749b09e79a3f986e90ceb",
  "tarball": "https://registry.npmjs.org/3box-react-hooks/-/3box-react-hooks-1.0.0.tgz",
  "fileCount": 8,
  "unpackedSize": 3474629,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcs2gNCRA9TVsSAnZWagAAk5sP/3gP00VSmNOJBKrF0NNO\nviK8kgJbFvITbXs4WMpmZQsiahgE7vksC0GQQ9Ajn8MpjQRKpSqPNmRdc3tB\nJKreJ6HyrzryajJBfKeDTexfLgjxnguG/HIoDsPx4FDZagTrvRBx5XJzEcAO\neUIQMJCBsenGoNOrbr2v8tPC9nn6UwFfHl5Zx8VlNZ59ozCbNKeNQp3KplkS\nKMC6Xu/TmaWQGJtT1AUWLTCQOJQk3fIBn/vWSsk2ibaI64KMNmINSFB3MXH0\nCWGvMn1kK0R1tCCdFeKiGLuZXRqH1LPZjq6Gp1jzitseuasbiZ86vKjLO8cp\nkdPx9HuBxZNpyqrWU3tIXuk6BRpOk48ILIprqJ6DZD6cdpS8+WmShJdbgnaX\nAco+0UsxJRi/VvpGGBnA/j4+hMCw4HfJrGLfuGJO+l5Jh2OmFG13BjbrO3wY\ndJNmMCypTZ+jLxYJzAG4u8kUY4bR2hnbcDqrJ+mm5NJbyafjjLvsX/byCphR\nXuOD6dCvKbXVfo/evz0SRMTDTxppatyuUFlmJbGPbn9MFO2TYdruPXuwxocr\nTIu78LgGg70kcZoZXeADqu9zhOrZhheP6I5Eiq4aVacsoxEaw4sF4ZlvkAaa\nOQke0ZVmXqIwRNY8xsZXNcg9KW8eEKPU5AcNOKzfdauDv2KwY+BmM1dcyMxA\nlDJE\r\n=9Zah\r\n-----END PGP SIGNATURE-----\r\n",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEYCIQDy8aWIhlYiUN5IuP4whdaOjwk18omQwInL+ED4AaDU8wIhAOZekV4GJd66wAAAL2bWERii0cMTFJzswwASQbXiC/EQ"
    }
  ]
}

Repository

PENDING
raksooo/3box-react-hooks

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 19:31 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:ec40273d56a88a70410c5c3d0fbf38d9b68aac0bca1967f13610faeea3ed2bf9

Other collected versions

2.0.130 May2.0.030 May1.1.425 Apr1.1.321 Apr1.1.218 Apr1.1.117 AprView all collected versions →