# react/forbid-dom-props 📝 Disallow certain props on DOM Nodes. This rule prevents passing of props to elements. This rule only applies to DOM Nodes (e.g. `
`) and not Components (e.g. ``). The list of forbidden props can be customized with the `forbid` option. ## Rule Details This rule checks all JSX elements and verifies that no forbidden props are used on DOM Nodes. This rule is off by default. Examples of **incorrect** code for this rule: ```jsx // [1, { "forbid": ["id"] }]
``` ```jsx // [1, { "forbid": ["style"] }]
``` Examples of **correct** code for this rule: ```jsx // [1, { "forbid": ["id"] }] ``` ```jsx // [1, { "forbid": ["id"] }] ``` ## Rule Options ```js ... "react/forbid-dom-props": [, { "forbid": [|] }] ... ``` ### `forbid` An array of strings, with the names of props that are forbidden. The default value of this option is `[]`. Each array element can either be a string with the property name or object specifying the property name, an optional custom message, DOM nodes disallowed list (e.g. `
`), and a list of prohibited values: ```js { "propName": "someProp", "disallowedFor": ["DOMNode", "AnotherDOMNode"], "disallowedValues": ["someValue"], "message": "Avoid using someProp" } ``` Example of **incorrect** code for this rule, when configured with `{ forbid: [{ propName: 'someProp', disallowedFor: ['span'] }] }`. ```jsx const First = (props) => ( ); ``` Example of **correct** code for this rule, when configured with `{ forbid: [{ propName: 'someProp', disallowedFor: ['span'] }] }`. ```jsx const First = (props) => (
); ``` Examples of **incorrect** code for this rule, when configured with `{ forbid: [{ propName: 'someProp', disallowedValues: ['someValue'] }] }`. ```jsx const First = (props) => (
); ``` ```jsx const First = (props) => ( ); ``` Examples of **correct** code for this rule, when configured with `{ forbid: [{ propName: 'someProp', disallowedValues: ['someValue'] }] }`. ```jsx const First = (props) => ( ); ``` ```jsx const First = (props) => (
); ``` ### Related rules - [forbid-component-props](./forbid-component-props.md)