
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
react-html-refs
Advanced tools
A collection of react hooks/providers to help you scroll by through life and focus on the right stuff.
Tired of React.RefObject
chains all-over your project?
Tired of document.querySelector?.('.meaning-of-life')
in a React app?
Do you want to manually focus on a html input across the application or scroll the user to a specific element? Yeah, me neither
Well then this project is for you!
With the code below you can manage all your html element related needs in your React app, just:
Destinations
provider, with your collection of useful handlersuseDestination
hook or Destination
component to register html element destinationsuseDestination
to apply code to your registered destinationsSee the example:
import React from 'react';
import { render } from 'react-dom';
import { useDestination, Destinations, Destination, Handler, chain, DebugLogger, silence, wrapUnknown } from 'react-html-refs';
type DestinationType = 'A';
type HandlerCategory = 'Focus' | 'Scroll';
const App = (): JSX.Element => {
const { handle } = useDestination<DestinationType, HandlerCategory>('A');
return (
<>
<Destination<DestinationType> destinationId="A">I am a destination</Destination>
<button onClick={() => handle(wrapUnknown((el) => el.scrollIntoView({ behavior: 'smooth' })))}>Scroll!</button>
<button onClick={() => handle('Focus')}>Scroll!</button>
</>
);
};
render(
<Destinations<HandlerCategory>
defaulHandler={chain(
silence(wrapUnknown((el) => el.scrollIntoView({ behavior: 'smooth' }))),
silence(wrapUnknown((el) => el.scrollTo({ behavior: 'smooth' }))),
wrapUnknown((el) => window.scrollTo(0, el.offsetTop)),
)}
handlers={{
Scroll: wrapUnknown((el) => window.scrollTo(0, el.offsetTop)),
Focus: wrapUnknown((el) => el.focus()),
}}
logger={new DebugLogger()}
>
<App />
</Destinations>,
document.querySelector('#app'),
);
If you are using typescript, I strongly recommend strongly typing your ids and handler categories so its easier to manage them.
FAQs
React html hooks to help us better manage html elements on React
We found that react-html-refs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.