Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

solid-ts-hooks

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

solid-ts-hooks

Solid-ts-hooks Solidjs hook library, ready to use, written in Typescript.

  • 0.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
increased by166.67%
Maintainers
1
Weekly downloads
 
Created
Source

Solid-ts-hooks

Solidjs hook library, ready to use, written in Typescript.


npm i solid-ts-hooks
yarn add solid-ts-hooks
pnpm add solid-ts-hooks

Created by Rnwonder. inspired by usehooks-ts

Hook List

  • createClickOutside
  • createLocalStorage
  • createDarkMode
  • createIntersectingObserver
  • createMap
  • createMediaQuery
  • createWindowScroll
  • createWindowSize

Usage

createClickOutside

import { createClickOutside} from "solid-ts-hooks";

const setRef = createClickOutside(() => {  
  console.log("click outside");  
});

return (
  <div ref={setRef}>Click outside me</div>
)

createLocalStorage

import { createLocalStorage } from "solid-ts-hooks";

const  [data, setData]  =  useLocalStorage('some-data',  {})

setData({ name: "Paul" })

return (
  <div>Your name is {data()?.name}</div>
)

createDarkMode

import { createDarkMode} from "solid-ts-hooks";

const { isDarkMode, enable, toggle, disable } = createDarkMode(true);

return (
  <div>Your mode is {isDarkMode() ? "Dark" : "Light"}</div>
)

createIntersectingObserver

import { createIntersectingObserver} from "solid-ts-hooks";

const { setRef, isVisible } = createIntersectingObserver({});

return (
  <div ref={setRef}>I am {isVisible() ? "visible" : "invisible"}</div>
)

createMap

import { createMap} from "solid-ts-hooks";

const  [map, actions]  =  createMap<string,  string>(initialValues)
    const  set  =  ()  => actions.set(String(Date.now()),  '📦')
	const  setAll  =  ()  => actions.setAll(otherValues)
	const  reset  =  ()  => actions.reset()
	const  remove  =  ()  => actions.remove('hello')

return (
  <div ref={setRef}>
	<button  onClick={set}>Add</button>
	<button  onClick={reset}>Reset</button>
	<button  onClick={setAll}>Set new data</button>
	<button  onClick={remove}  disabled={!map.get('hello')}>
		{'Remove "hello"'}
	</button>
</div>
)

createMediaQuery

import { createMediaQuery } from "solid-ts-hooks";

const matches =  createMediaQuery ('(min-width: 768px)')

return (
  <div>{`The view port is ${matches ?  'at least'  :  'less than'} 768 pixels wide`}</div>
)

createWindowScroll

import { createWindowScroll} from "solid-ts-hooks";

createWindowScroll(() => {
 console.log("scroll")
})

createWindowSize

import { createWindowSize} from "solid-ts-hooks";

const { width, height} =  createWindowSize()

console.log(width(), height())

Buy Me A Coffee

Keywords

FAQs

Package last updated on 05 Jun 2023

Did you know?

Socket

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.

Install

Related posts

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