react-sanitize-dom-props
v0.0.1
Published
This package helps to remove extra properties from object and leave only ones that are valid for passing to dom.
Downloads
233
Readme
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