Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
treble-hook
Advanced tools
yarn add treble-hook
or
npm install --save treble-hook
Contrived sign-in component along with component that displays active user (signed-in user).
import React, { ChangeEvent, useState } from 'react'
import { usePubSub } from 'treble-hook'
const ACTIVE_USER_TOPIC = 'active-user'
function SignIn() {
// publishUser will do just that, publish the value
// to all subscribers of the ACTIVE_USER_TOPIC
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() {
// this subsribes the component to the ACTIVE_USER_TOPIC and
// whenever the active user is published (from anywhere in the
// app) it will get updated here. Also, this component doesn't
// have to wait for the next publish, it will intialize with
// the last published value or default to 'Anonymous' otherwise
const [activeUser] = usePubSub<string>(
ACTIVE_USER_TOPIC,
'Anonymous'
)
return (
<div>
Active user: { activeUser }
</div>
)
}
Brought to you by the engineering team at Igneous. Speaking of, we're always on the lookout for fun-loving, passionate engineers; visit Igneous culture and careers to learn more.
FAQs
Get hooked on simple subscribe-and-publish in ReactJS.
The npm package treble-hook receives a total of 4 weekly downloads. As such, treble-hook popularity was classified as not popular.
We found that treble-hook demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.