New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

treble-hook

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

treble-hook - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

2

package.json
{
"name": "treble-hook",
"version": "1.0.4",
"version": "1.0.5",
"description": "Get hooked on simple subscribe-and-publish in ReactJS.",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -12,12 +12,56 @@ <div align="center">

### yarn
```sh
yarn add @igneous.io.ux/treble-hook
yarn add treble-hook
```
### npm
### or
```sh
npm install --save @igneous.io.ux/treble-hook
npm install --save treble-hook
```
## Usage
Contrived sign-in component and a component that displays active user (signed-in user).
```tsx
import React, { ChangeEvent, useState } from 'react'
import usePubSub from 'treble-hook'
const ACTIVE_USER_TOPIC = 'active-user'
function SignIn() {
const [_, publishUser] = usePubSub<string>(ACTIVE_USER_TOPIC, '')
const [entered, setEntered] = useState<string>('')
return (
<div>
<input
type='text'
onChange={
(evt: ChangeEvent<HTMLInputElement>) => {
setEntered(evt.target.value)
}
}
/>
<button onClick={ () => { publishUser(entered) }}>Sign-in</button>
</div>
)
}
function ActiveUser() {
const [activeUser] = usePubSub<string>(
ACTIVE_USER_TOPIC,
'Anonymous'
)
return <h3>Active user: { activeUser }</h3>
}
```
## TLDR; (jump right into it)

@@ -27,6 +71,6 @@

```TSX
```tsx
import usePubSub from '@igneous.io.ux/treble-hook'
import React, { FC } from 'react'
import React from 'react'
import usePubSub from 'treble-hook'
import { BluePicker, GreenPicker, RedPicker } from './color-buttons'

@@ -65,6 +109,6 @@

```JSX
```tsx
import usePubSub from '@igneous.io.ux/treble-hook'
import React from 'react'
import usePubSub from 'treble-hook'

@@ -71,0 +115,0 @@ const ColorButton = <{ cn: string }>({ cn }) => {

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