@filecoin-shipyard/use-filecoin-config

0.0.11 • Public • Published

@filecoin-shipyard/use-filecoin-config

React hook to load config via Filecoin API

Uses js-filecoin-api-client to connect to the go-filecoin HTTP API running on localhost.

Note: Even though it is a React hook, it was built to be used in command-line apps that run in a Node.js environment, it has not yet been used in the browser.

Example

From filecoin-big-head which uses React with Ink in a Node.js interactive command-line app:

import useFilecoinConfig from '@filecoin-shipyard/use-filecoin-config'

const Main = () => {
  const [nickError, nickname] = useFilecoinConfig('heartbeat.nickname')

  return <Box>{nickname && nickname}</Box>
}

API

useFilecoinConfig(key, [options])

Parameters

Name Type Description
key String Dot separated key to config value to retrieve
options Object Optional options
options.interval Number Requery the config value every interval milliseconds (Default: 1000)

Returns

Returns an array of values, like other React hooks.

Index Type Description
0 Error Error object or null
1 ? Value from config

License

MIT/Apache-2 (Permissive License Stack)

Readme

Keywords

none

Package Sidebar

Install

npm i @filecoin-shipyard/use-filecoin-config

Weekly Downloads

2

Version

0.0.11

License

MIT

Unpacked Size

8.26 kB

Total Files

4

Last publish

Collaborators

  • npm-service-account-filecoin-shipyard
  • jimpick
  • alanshaw
  • lidel
  • achingbrain
  • stebalien
  • dignifiedquire
  • mikeal
  • dietrich
  • rvagg
  • vascosantos