'Why !important is not working in react js with inline style

I am using inline style in react js like

style={{ textAlign: "center !important;" }}


Solution 1:[1]

As it is not possible in reactJs, please read this article https://github.com/facebook/react/issues/1881#issuecomment-262257503

But there is a way you can still use it :

<div ref={element => { 
         if (element) element.style.setProperty('textAlign', 'center', 'important'); 
       }}
/>

Solution 2:[2]

You can use it like this:

<div ref={(node) => {
    if (node) {
        node.style.setProperty("float", "right", "important");
    }
}}>
                
</div>

Solution 3:[3]

try simple without "!important;"

style={{ textAlign: "center" }}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sarvesh Mahajan
Solution 2 Stanciu Patrick
Solution 3 dazn311