Security News
Highlights from the 2024 Rails Community Survey
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
@emotion/is-prop-valid
Advanced tools
A function to check whether a prop is valid for HTML and SVG elements
The @emotion/is-prop-valid package is a utility for checking if a given property is a valid HTML or SVG attribute. It is commonly used in CSS-in-JS libraries, such as Emotion, to filter out props that should not be passed to DOM elements to avoid React warnings about unknown DOM props.
Checking HTML validity of a prop
This feature allows you to check if a prop is a valid HTML attribute. It returns true for valid attributes like 'onClick' and false for non-standard or invalid attributes like 'randomPropName'.
import isPropValid from '@emotion/is-prop-valid';
console.log(isPropValid('onClick')); // true
console.log(isPropValid('randomPropName')); // false
Checking SVG validity of a prop
This feature allows you to check if a prop is a valid SVG attribute. It returns true for valid attributes like 'viewBox' and false for non-standard or invalid attributes like 'randomSVGProp'.
import isPropValid from '@emotion/is-prop-valid';
console.log(isPropValid('viewBox')); // true
console.log(isPropValid('randomSVGProp')); // false
The prop-types package is used for runtime type checking for React props. While it doesn't provide the same functionality as @emotion/is-prop-valid, it is used to ensure that components receive props of the correct type.
Styled-components is a CSS-in-JS library that allows you to write CSS code for components within JavaScript. It has a similar feature to @emotion/is-prop-valid where it filters out non-HTML attributes from being passed to DOM elements.
This package contains a list of all standard HTML attributes and can be used to check if a prop is a valid HTML attribute, similar to what @emotion/is-prop-valid does.
Check whether a prop is valid for HTML and SVG elements
yarn add @emotion/is-prop-valid
import isPropValid from '@emotion/is-prop-valid'
isPropValid('href') // true
isPropValid('someRandomProp') // false
FAQs
A function to check whether a prop is valid for HTML and SVG elements
The npm package @emotion/is-prop-valid receives a total of 11,031,415 weekly downloads. As such, @emotion/is-prop-valid popularity was classified as popular.
We found that @emotion/is-prop-valid demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.