score:1
1. config sass modules
if you created your project with create-react-app, only thing you need to do is adding module prefix to your filename.
rename button.scss to button.module.scss
but if not, you should set modules option to true inside your sass-loader.
// webpack.config.js
module: {
rules: [
{
test: /\.(sass|scss)$/,
use: [
{
loader: 'sass-loader',
options: {
modules: true
},
},
],
},
],
},
2.change your jsx to following
import buttonstyles from 'button.module.scss'
<button classname={buttonstyles.button__primary}>submit</button>
Source: stackoverflow.com
Related Query
- Convert sass styles to inline styles object in react
- Convert React inline styles to CSS rules
- lodash , convert string from svg circle (properties and values separates with space) to object for spread in react component inline
- REACT Cant convert my styling to inline styles
- Setting a backgroundImage With React Inline Styles
- !important inline styles in react
- Setting Complex react inline styles such as hover, active on react components such as button
- Cannot convert object to primitive value error in react application?
- React Native inline styles and performance
- Convert react JSX object to HTML
- Adding inline styles to react
- How to write inline styles in react
- Convert object to array in Javascript / React
- How to convert object to string in react js
- React Native: All styles in StyleSheet object after exporting were converted to number type
- React - Importing non-modular sass file returns empty object
- Cannot convert undefined or null to object in react
- Is it ok to convert Immutable.js Map to Object inside of react component
- Setting a dynamic backgroundImage With React inline styles
- Modifying React style object seems to corrupt dom styles
- FormData object from React doesnt convert on backend C# to model
- Can component styles be scoped instead of inline to prevent overwriting by multiple React apps on the same page?
- TypeError: Cannot convert undefined or null to object React Validation
- React - convert object into array of objects with properties
- Applying conditional styles to a component in React - Inline CSS
- React inline styles, applying styles from state
- React imported library throws error: cannot convert undefined or null to object
- React can not convert undefined or null to object
- Inline styles in react doesnt work in print mode
- React sees inline style attribute as a string even though I'm passing an object
More Query from same tag
- CSS Center and Left Alignment Issue
- Unable to open react application from another broswer
- How can I make all three containers draggable in Dragula, if all three are rendered using a method? Using React js and Dragula (not react-dragula)
- Fetch request is not updating the state
- react js nested Routers SecurityError:
- Trigger 'resize' event on component?
- React - express expected in map function
- Reactjs state while value setted throw undefined error
- How to redirect home in ReactJS
- Use parent prop on child component prop
- Showing 2 different states from the same reducer without the state rewrites itself
- How to prevent component displaying before redirecting?
- Trouble passing props down to components, specifically two levels down - React Router, Javascript
- Why does my state not change or work the first time I click submit in React
- Retrieve props of each child in a loop to use a value as a key react
- How to filter arrays in a JSON by multiple tags
- Why does the Material-UI Select does not display any option?
- Webpack - Build css not applied
- Axios api call returns not found error in reactjs
- trying to pass a value from child component to the parent component in react js
- React - What's the great benefit of having immutable props?
- Netlify deploy with results of TypeError: Cannot read property 'replace' of undefined
- Loading images based on JSON file react
- Auto-Scrolling A Flexbox Column With A Sticky NavBar
- Using hover-effect in Next JS
- useCallback Hooks getting old state values and not updating
- react component method binding with arrow function (class properties)
- Can I safely use both the "to" and "onClick" props on a React Router Link?
- How to calculate inside React states?
- How to do validation using useRef()