This package has been deprecated

Author message:

Package no longer supported. Use at your own risk.

ironhook-react
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

ironhook-react

Allows easy use of Hooks written with Ironhook in React.

Installation

Using yarn:

yarn add ironhook-react

Using npm:

npm install ironhook-react --save

Usage Example

The following is a constructed example that demonstrates the use of this library:

import * as Ironhook from 'ironhook';
import * as IronhookReact from 'ironhook-react';
import * as React from 'react';

function useName() {
  const [name, setName] = Ironhook.useState('World');

  Ironhook.useEffect(() => {
    setTimeout(() => setName('John Doe'), 10);
  }, []);

  return name;
}

function Hello() {
  const nameSubject = React.useMemo(() => new Ironhook.Subject(useName), []);
  const nameResult = IronhookReact.useIronhook(nameSubject);

  switch (nameResult.type) {
    case 'value':
      return <h1>Hello, {nameResult.value}!</h1>;
    case 'error':
      return <h1>Oops!</h1>;
    case 'completed':
      return <h1>Bye.</h1>;
  }
}
<Hello />

API Reference

Types

function useIronhook<TValue>(
  subject: Ironhook.Subject<TValue>
): IronhookResult<TValue>;
type IronhookResult<TValue> =
  | {readonly type: 'value'; readonly value: TValue}
  | {readonly type: 'error'; readonly error: Error}
  | {readonly type: 'completed'};

Development

Publish A New Release

yarn release patch
yarn release minor
yarn release major

After a new release has been created by pushing the tag, it must be published via the GitHub UI. This triggers the final publication to npm.


Copyright (c) 2020, Clemens Akens. Released under the terms of the MIT License.

Readme

Keywords

none

Package Sidebar

Install

npm i ironhook-react

Weekly Downloads

3

Version

0.2.0

License

MIT

Unpacked Size

14.1 kB

Total Files

15

Last publish

Collaborators

  • clebert