I’ve no clue how to fix this as am new to REACT-NEXT (am an Angular guy). Below is element that am utilizing from another resource like
import example-custom-ele-parent, {example-custom-ele-child} from 'custom-tags/example-custom'
<example-custom-ele-parent>
<example-custom-ele-child></example-custom-ele-child>
</example-custom-ele-parent>
when I see css for example-custom-ele-child
in my localhost:3008 , in chrome browser, it is like
.cqAcqQ {
padding: 0.25rem;
}
I want to add one rule so added in globals.css file, like
.cqAcqQ {
padding: 0.25rem;
margin: 2rem !important; // newly added by me
}
Everything was working in my localhost fine. But after i deployed, the changes i made overridden with new random class and its became
.kXIDVb {
padding: 0.25rem;
}
Current package versions are
"next": "13.0.7",
"next-transpile-modules": "10.0.0",
"react": "18.2.0",
"react-dom": "18.2.0",
I tried override by doing <example-custom-ele-child className={style['my-change']}></example-custom-ele-child>
but getting error like className={style[‘my-change’] is not allowed
Could someone please guide me on this?
Thanks
2
Answers
Try to add styles like so:
But if u need to add something like font-size, in this case:
Hope it helps!
First topic – class name change
Answer: by the name of the class cqAcqQ I am suspecting this is a auto generated class which means with each build it will have a new name. In this case it changed to kXIDVb. Maybe you are using a third party component like material-ui or bootstrap. they seem to generate random classNames with each build. If you share the child element code I can confirm you.
Second Topic – why adding className to component not working
Answer: the reason is you are putting the className property to a custom component. If you want to add className like this
you need to make sure in the definition of this component you are handling this prop. for ex.
Let me know if it helps or you can comment here with your questions.