0.0.1 • Published 4 years ago

react-sanitize-dom-props v0.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

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