npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@hairy/react-lib-composition

v1.51.0

Published

Library for react reactivity

Readme

@hairy/react-lib-composition

npm version npm downloads bundle size license

React reactivity layer built on top of @vue/reactivity.

Install

# ✨ Auto-detect
npx nypm install @hairy/react-lib-composition

# npm
npm install @hairy/react-lib-composition

# yarn
yarn add @hairy/react-lib-composition

# pnpm
pnpm add @hairy/react-lib-composition

# bun
bun install @hairy/react-lib-composition

# deno
deno install npm:@hairy/react-lib-composition

API

computed(arg1, arg2)

customRef(factory)

Creates a customized ref with explicit control over its dependency tracking and updates triggering.

defineComponent()

effectScope()

Creates an effect scope object which can capture the reactive effects (i.e. computed and watchers) created within it so that these effects can be disposed together. For detailed use cases of this API, please consult its corresponding {@link https://github.com/vuejs/rfcs/blob/master/active-rfcs/0041-reactivity-effect-scope.md | RFC}.

Fragment

  • Type: symbol
  • Default: undefined

getCurrentInstance()

getCurrentScope()

Returns the current active effect scope if there is one.

h()

hasInjectionContext()

inject()

isProxy()

isReactive()

isReadonly()

isRef()

isShallow()

markRaw()

nextTick()

onBeforeMount(fn)

onBeforeUnmount(fn)

The function is called right before the component is unmounted.

onBeforeUpdate(fn)

onMounted(fn)

The function is called right after the component is mounted.

onScopeDispose(fn, _failSilently)

Registers a dispose callback on the current active effect scope. The callback will be invoked when the associated effect scope is stopped.

onUnmounted(fn)

onUpdated(fn)

The function is called immediately after the component is re-rendered with updated props or state. This method is not invoked during the initial render.

provide()

reactive(target)

reactivity(getter)

Converts some of the 'raw Vue' data, which is not already wrapped in a hook, into reactive hook data to ensure proper reactivity within the component.

Example:

import React from 'react'
import { ref, reactivity } from 'veact'

const countRef = ref(0)

export const Component: React.FC = () => {
  // Convert to a reactivity hook
  const count = reactivity(() => countRef)
  const increment = () => {
    count.value++
  }

  return (
    <div>
      <span>{count.value}</span>
      <button onClick={increment}>Increment</button>
    </div>
  )
}

readonly(target)

Takes an object (reactive or plain) or a ref and returns a readonly proxy to the original.

A readonly proxy is deep: any nested property accessed will be readonly as well. It also has the same ref-unwrapping behavior as {@link reactive()}, except the unwrapped values will also be made readonly.

Example:

const original = reactive({ count: 0 })
const copy = readonly(original)

useWatchEffect(() => {
  // works for reactivity tracking
  console.log(copy.count)
})

// mutating original will trigger watchers relying on the copy
original.count++

// mutating the copy will fail and result in a warning
copy.count++ // warning!

ref(initValue?)

shallowReactive(target)

Shallow version of {@link reactive()}.

Unlike {@link reactive()}, there is no deep conversion: only root-level properties are reactive for a shallow reactive object. Property values are stored and exposed as-is - this also means properties with ref values will not be automatically unwrapped.

Example:

const state = shallowReactive({
  foo: 1,
  nested: {
    bar: 2
  }
})

// mutating state's own properties is reactive
state.foo++

// ...but does not convert nested objects
isReactive(state.nested) // false

// NOT reactive
state.nested.bar++

shallowReadonly(target)

Shallow version of {@link readonly()}.

Unlike {@link readonly()}, there is no deep conversion: only root-level properties are made readonly. Property values are stored and exposed as-is - this also means properties with ref values will not be automatically unwrapped.

Example:

const state = shallowReadonly({
  foo: 1,
  nested: {
    bar: 2
  }
})

// mutating state's own properties will fail
state.foo++

// ...but works on nested objects
isReadonly(state.nested) // false

// works
state.nested.bar++

shallowRef(initValue?)

toRaw()

toReactive()

toReadonly()

toRef()

toRefs()

toValue()

TransitionGroup()

unref()

watch(source, callback, options)

watchEffect(effect, options)

Runs a function immediately while reactively tracking its dependencies and re-runs it whenever the dependencies are changed.

Example:

const count = useRef(0)
watchEffect(() => console.log(count.value))
// -> logs 0

count.value++
// -> logs 1

withEffectScope(fn, detached?)

Directory structure

├── src/
│   ├── computed.ts
│   ├── effectScope.ts
│   ├── index.ts
│   ├── inject.ts
│   ├── lifecycle.ts
│   ├── reactive.ts
│   ├── reactivity.ts
│   ├── readonly.ts
│   ├── ref.ts
│   ├── watch.ts
│   └── watchEffect.ts
├── macros-global.d.ts
├── package.json
├── README.md
└── tsdown.config.ts

Source

import { noop } from '@hairy/utils'

export * from './computed'
export * from './effectScope'
export * from './lifecycle'
export * from './reactive'
export * from './reactivity'
export * from './readonly'
export * from './ref'
export * from './watch'
export * from './watchEffect'

export {
  isProxy,
  isReactive,
  isReadonly,
  isRef,
  isShallow,
  markRaw,
  toRaw,
  toReactive,
  toReadonly,
  toRef,
  toRefs,
  toValue,
  unref,
} from '@vue/reactivity'
export {
  Fragment,
  createElement as h,
} from 'react'
export const getCurrentInstance = noop
export const hasInjectionContext = noop
export const inject = noop
export const provide = noop
export const nextTick = noop
export const defineComponent = noop
export const TransitionGroup = noop

Contributors

Published under the MIT license. Made by @Hairyf and community 💛

License

MIT License

Copyright (c) 2025-PRESENT Hairyf https://github.com/hairyf

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


🤖 auto updated with automd