npm.io
0.0.1 • Published 5 years ago

react-sanitize-dom-props

Licence
MIT
Version
0.0.1
Deps
0
Size
138 kB
Vulns
0
Weekly
0
Stars
1

React Sanitize DOM Props

This package helps to remove extra properties from object and leave only ones that are valid for passing to dom.

Usage

import { pickHTMLProps } from "react-sanitize-dom-props";
const props = {
    onClick: () => {},
    className: "container",
    foo: "bar"
}

const sanitizedPorps = pickHTMLProps(props, /* strict */ false);
/* {
    onClick: () => {},
    className: "container",
} */
import { isValidHTMLProp } from "react-sanitize-dom-props";

isValidHTMLProp("onClick" /* strict */ false); // true
isValidHTMLProp("onClick" /* strict */ true); // true
isValidHTMLProp("onclick" /* strict */ false); // true
isValidHTMLProp("onclick" /* strict */ true); // false