
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
react-filter-element
Advanced tools
Use this hook to easily filter out your html element within a parent element.
Installation
$ npm i react-filter-element
Import useFilterElement hook from the module
import React from 'react';
import useFilterElement from 'react-filter-element';
You also need to import useRef hook from react to target the parent element
import React,{useRef} from 'react';
import useFilterElement from 'react-filter-element';
Next you need to use the useRef hook to target the element and pass the element when calling the useFilterElement hook
const parent = useRef(null);
const [filter,items] = useFilterElement(parent); // calling the hook with the parent
<div ref={parent}></div> // html
you will get back filter and items from the hook. filter refers to the main function to use the filter and items contains the childs
Now call the function with a key name as argument and set the key name as a class of the childs ( you can also pass * as key , it will show every child)
<button onClick={() => filter('bird')}>Birds</button>
<button onClick={() => filter('fish')}>Fish</button>
<div className="bird">
<h1>Bird</h1>
</div>
<div className="fish">
<h1>Fish</h1>
</div>
full sample code
import React,{useRef} from 'react';
import useFilterElement from 'react-filter-element';
const parent = useRef(null);
const [filter,items] = useFilterElement(parent); // calling the hook with the parent
// html
<button onClick={() => filter('bird')}>Birds</button>
<button onClick={() => filter('fish')}>Fish</button>
<div ref={parent}>
<div className="bird">
<h1>Bird</h1>
</div>
<div className="fish">
<h1>Fish</h1>
</div>
</div>
Live working demo here
FAQs
use this package to easily filter out html elements in react
We found that react-filter-element 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.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.