How to use @bem-react/classname - 1 common examples

To help you get started, we’ve selected a few @bem-react/classname examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bem / bem-react / packages / core / core.tsx View on Github external
return function WithBemMod(
    WrappedComponent: ComponentType,
  ) {
    // Use cache to prevent create new component when props are changed.
    let ModifiedComponent: ComponentType
    let modifierClassName: string
    entity = entity || cn(blockName)
    entityClassName = entityClassName || entity()

    function BemMod(props: T & K) {
      modNames = modNames || Object.keys(mod)
      // TODO: For performance can rewrite `every` to `for (;;)`.
      const isModifierMatched = modNames.every((key: string) => {
        const modValue = mod[key]
        const propValue = (props as any)[key]

        return modValue === propValue || (modValue === '*' && Boolean(propValue))
      })

      if (isModifierMatched) {
        const modifiers = modNames.reduce((acc: Dictionary, key: string) => {
          if (mod[key] !== '*') acc[key] = mod[key]

@bem-react/classname

BEM React ClassName

MPL-2.0
Latest version published 1 year ago

Package Health Score

63 / 100
Full package analysis

Popular @bem-react/classname functions