Error: The `style` prop expects a mapping from style properties to values, not a string.

Minta pencerahan nya dong, saya baru belajar react js.. ini ada error kaya gitu setelah saya masukan koding dari template bootstrap muat munculin image
error.pngerror.PNGimage

<div class="slider-item" data-dot="&lt;i class=&quot;fa fa-bicycle&quot;&gt;&lt;/i&gt; Invent" style="background-image: url(images/slider/bg1.jpg);">
            <div class="overlay2">
                <div class="container h-100">
                    <div class="row h-100 align-items-center">
                        <div class="col-12">
                            <h2 data-duration-in=".3" data-animation-in="fadeInUp">Need To Invent The Future!</h2>
                            <h3 class="mb-4" data-duration-in=".4" data-animation-in="fadeInUp" data-delay-in=".4">We Making Difference To Great Things Possible</h3>
                            <a href="#0" class="btn btn-primary white m-2" data-duration-in=".5" data-animation-in="fadeInUp" data-delay-in=".5">Start Now</a>
                            <a href="#0" class="btn btn-primary solid m-2" data-duration-in=".6" data-animation-in="fadeInUp" data-delay-in=".6">Learn More</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
avatar Obbytokun

@Obbytokun

164 Kontribusi 9 Poin


Jawaban

Halo @Obbytokun

Mohon Izin menjawab,

Ubah pada bagian:
style="background-image: url(images/slider/bg1.jpg);

menjadi:
const divStyle = {
  backgroundImage: 'url(images/slider/bg1.jpg)',
};

styles={divStyle}

Sumber:
https://reactjs.org/docs/dom-elements.html#style
https://stackoverflow.com/questions/50526021/uncaught-error-the-style-prop-expects-a-mapping-from-style-properties
avatar keccikun

@keccikun

353 Kontribusi 191 Poin


Login untuk gabung berdiskusi