1

Hey there I want to change the style of my entire website. For this, I want to switch the style sheet in react. How can I do this ?

I used jquery to solve this, but it didn't work in react.

$(function () {
    $(document).ready(function () {
        $(".navbar").show();
        (function ($j) {
            switch_style = {
                onReady: function () {
                    this.switch_style_click();
                },
                switch_style_click: function () {
                    $(".style-changer").click(function () {
                        var id = $(this).attr("id");
                        $("#switch_style").attr("href", "css/" + id + ".css");
                    });
                },
            };
            $j().ready(function () {
                switch_style.onReady();
            });
        })(jQuery);
        $(function () {
            $(window).scroll(function () {
                if ($(this).scrollTop() > 250) {
                    $(".navbar").fadeOut();
                } else {
                    $(".navbar").fadeIn();
                }
            });
        });
    });
}(jQuery));
Waleed Iqbal
  • 1,308
  • 19
  • 35
syed haris
  • 11
  • 1
  • I'd recommending exploring CSS in JS solutions for something like this. [JSS](http://cssinjs.org/). Bonus points: They work really well with react – Chirag Ravindra Mar 15 '18 at 11:22
  • possible duplicate: https://stackoverflow.com/questions/28386125/dynamically-load-a-stylesheet-with-react – Hai Alaluf Mar 15 '18 at 11:29

0 Answers0