Browsing index pages (4 articles)
↧
How to get rid of the "className" attribute in JSX?
My JSX files are full of:<div className="...">...</div>For example:const Page = () => (<div className="Page"><div className="sideMenu"><Route path="/"...
View ArticleAnswer by Simonov Dmitry for How to get rid of the "className" attribute in JSX?
You can do it like this: class Div extends React.Component { render() { return (<div className={this.props.cl} > {this.props.children}</div> ); } }; export default Div;And use<Div...
View ArticleAnswer by Przemysław Zalewski for How to get rid of the "className" attribute...
You should consider using a simple Styled component for that case that handles all true boolean properties as class names and joins them as a string using classnames.class Styled extends...
View ArticleAnswer by Jonny Buchanan for How to get rid of the "className" attribute in JSX?
You could write a Babel plugin for it - e.g. babel-plugin-react-html-attrs allows you to use class and for attributes when working with JSX in React and changes them to the className and htmlFor...
View Article
Browsing index pages (4 articles)