I am changing language dynamically, so I want to switch from rtl to ltr and vice-versa.
I am using bootstrap-rtl for rtl support.
Here is my code:
componentWillReceiveProps(nextProps) {
if (this.props.isRTL !== nextProps.isRTL) {
if (nextProps.isRTL) {
require('bootstrap-rtl/dist/css/bootstrap-rtl.css');
} else {
//what should i do here????????????
}
}
}
So, when component first renders,
english
is selected. So,isRTL is false
. As a resultrequire('........bootstrap-rtl.css')
doesn't come to play.Now, When I change language to
arabic
,isRTL becomes true
andbootstrap-rtl.css
isrequired
. Now, I can see everythingrtl
.Now, when I again change language to
english
,isRTL becomes false
, butbootstrap-rtl.css
is notunrequired
, so still I see everythingrtl
.
Can someone suggest me the solution or even alternate solution is acceptable for me.