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,
englishis 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 trueandbootstrap-rtl.cssisrequired. Now, I can see everythingrtl.Now, when I again change language to
english,isRTL becomes false, butbootstrap-rtl.cssis notunrequired, so still I see everythingrtl.
Can someone suggest me the solution or even alternate solution is acceptable for me.