![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
bem-cx is designed for generating css classNames for use primarily in react components. It doesn't depend on react, so you could use it elsewhere.
bem-cx is designed for generating css classNames for use primarily in react components. It doesn't depend on react, so you could use it elsewhere.
npm install bem-cx
The docs can be found in the docs directory, though they might not make sense without the examples below.
There are two flavors of bem-cx. The first is very simple but requires more typing. The example is in JSX.
import makeBem from 'bem-cx'; // or require('bem-cx').default
const bem = makeBem('Foo');
class Foo {
render(){
return (
<div className={bem}>
Foo
<div className={bem.el('Header')}>
Foo__Header
<div className={bem.el('Header').el('Title')}>
Foo__Header__Title
</div>
</div>
<div className={bem.el('Content')}>
<div className={bem.el('Content').el('Example').mod(true && 'active')}>
Foo__Content__Example Foo__Content__Example--active
</div>
<div className={bem
.el('Content')
.el('Example')
.mod({
a: true,
b: false,
c: false
})}
>
Foo__Content__Example
Foo__Content__Example--a
Foo__Content__Example--c
</div>
</div>
</div>
);
}
}
This is the same as above but uses CxStack. CxStack has the same
api as the above but also provides .elAt
takes a level as its first argument.
Level 0 is the root, so direct children of the root node will have the level 1.
This saves you from needing to type everything on the hierarchy for each element.
Aside from .mod
this is the main value proposition of this library.
import {CxStack} from 'bem-cx'; // or require('bem-cx').CxStack
class Foo {
render(){
const bem = new CxStack('Foo');
return (
<div className={bem}>
Foo
<div className={bem.elAt(1, 'Header')}>
Foo__Header
<div className={bem.elAt(2, 'Title')}>
Foo__Header__Title
</div>
</div>
<div className={bem.elAt(1, 'Content')}>
<div className={bem.elAt(2, 'Example').mod(true && 'active')}>
Foo__Content__Example Foo__Content__Example--active
</div>
<div className={bem
.elAt(2, 'Example')
.mod({
a: true,
b: false,
c: false
})}
>
Foo__Content__Example
Foo__Content__Example--a
Foo__Content__Example--c
</div>
</div>
</div>
);
}
}
FAQs
bem-cx is designed for generating css classNames for use primarily in react components. It doesn't depend on react, so you could use it elsewhere.
We found that bem-cx demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.