What's causing my React app's slideshow to malfunction?

Struggling with styling my React app after importing w3.css and attempting to create a slideshow with 3 images in the same directory as the component being rendered. As someone new to React and web development, I'm facing challenges in getting the desired outcome.

import React, { Component } from "react";
import "w3-css/w3.css";

export default class Home extends Component {
render() {
return (
<div className="w3-container">
<div className="w3-content w3-display-container">
<img className="mySlides" src={"./1.jpg"} />
<img className="mySlides" src={"./2.jpg"} />
<img className="mySlides" src={"./3.jpg"} />
<div
className="w3-center w3-display-bottommiddle"
style="width:100%"
>
<div className="w3-left" onclick="plusDivs(-1)">
&#10094;
</div>
<div className="w3-right" onclick="plusDivs(1)">
&#10095;
</div>
<span
className="w3-badge demo w3-border"
onclick="currentDiv(1)"
/>
<span
className="w3-badge demo w3-border"
onclick="currentDiv(2)"
/>
<span
className="w3-badge demo w3-border"
onclick="currentDiv(3)"
/>
</div>
</div>
</div>
);
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

Challenges faced while following the steps outlined here for creating a slideshow. Errors encountered are also provided along with the link to the image of the error displayed on the local host page. Error Message Received: The style prop requires a mapping from style properties to values, not just a string.

Answer №1

modify

<div
    className="w3-center w3-display-bottommiddle"
    style="width:100%"
>

into

<div
    className="w3-center w3-display-bottommiddle"
    style={{width:"100%"}}
>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Preserve the values of checkboxes throughout the entire website by utilizing localStorage

Example A functionality in the example allows users to add images to a container by clicking on checkboxes. However, there is an issue where when a checkbox is checked on one page to store an image, and then another checkbox is checked on a different page ...

What steps can I take to resolve the upstream dependency error? I've attempted using commands like npm install --legacy-peer-deps and npm install --force, but they seem to create additional

I encountered the following error and would like to understand why such errors occur and if there is a way to update npm to match the version of React I have: PS C:\Naman Kothari\udemy course\react\thelastone> npm i react-tilt npm ER ...

Angular promise did not assign a value to a variable

Can someone assist me with a problem I'm facing? After the first callback, the variable doesn't seem to change as expected. Below is my code snippet: this.handlerLocalDef = function(defer) { var hash = {}; defer.then( ...

The main menu items in jQuery do not display the child sub menu upon clicking

I'm currently in the process of creating a unique mobile menu for my Wordpress website, but I'm facing some challenges when it comes to displaying and hiding the sub-menu items. I've assigned the class name .menu-item-has-children as my sele ...

Showing and hiding nested Form Group validation in Angular 4 is a crucial feature that can improve

I have been exploring Angular 4 validation recently. Currently, I am working with a reactive form that contains two radio buttons and two form groups. The behavior I'm trying to achieve is when the user selects the first radio button, it removes valid ...

Tips for preserving additional information in a form by selecting "add more" option

Recently, I encountered a challenge with a form on my website. Whenever a user fills out a few fields and clicks "Add", the data transitions into an HTML element. Subsequently, the form partially clears for more data input. Now I'm faced with the dil ...

Processing hover attributes in Tailwind-styled-components

I'm currently working on a website that features a dark mode, and I want to utilize the dark prop in tailwind-styled-components. The props work fine in all instances except for actions like hover, active, focus, etc. When attempting to use hover and t ...

Execute the component function located within one page using another page

Can someone help me understand how to trigger OnSwipe from inside a different JS file named CardFooter.js? This file contains a button with an OnClick event that triggers OnSwipe from the preceding JS file called CardItem.js. Both of these files are includ ...

Struggling to import the file even though it is clearly present

After spending hours trying to troubleshoot this persistent error, I've hit a wall. The dreaded message 'Module not found: Error: Can't resolve' keeps popping up no matter what I do. From my extensive search on Google, it seems like th ...

Error in React Native Typescript: The type 'string' cannot be assigned to the type '"solid" | "clear" | "outline"'. (Error code: ts(2322))

I have integrated TypeScript with React Native in my project. import React from 'react'; import { Button } from 'react-native-elements'; import { IThemedButton } from '../../../models/themedButton'; interface IThemedButtonPr ...

Creating a duplicate of a Flex object in HTML without the need to reinitialize

I'm currently developing a flash object that involves processing a large number of images. My goal is to load multiple flash objects on the same page in order to capture an image, make adjustments, and then display it within each flash object. Howeve ...

Encountered a server error when utilizing Next.js in conjunction with React

import React from 'react'; import { Layout } from '../components' import '../styles/globals.css'; function MyApp({ Component, pageProps }) { return ( <Layout> <Component {...pageProps} /> </Layo ...

What causes the variation in the appearance of the navigation bar across different pages?

I'm struggling to understand why the Navigation bar has extra padding or margin on top only on certain pages, while it looks fine on the Homepage. I've dedicated countless hours to this issue and I am feeling completely frustrated. If you' ...

Calculating the position of an element in an array passed from a separate file with ReactJS and Ant Design

I'm currently working with a file that contains some JavaScript code featuring an array with multiple objects containing key-value pairs. In my main file (App.jsx), I initialize a State Variable and assign it the array from another JS file. My goal no ...

Encountering an issue with a cyclic object value error when trying to access the state after modifying it

Hey there, I'm currently immersed in a react-native project where I've set up a form to update the state as inputs are filled out. However, when I try to access my state later on, I encounter an error stating cyclic object value. Upon delving i ...

What is the best way to update a specific element within a web page?

My current implementation involves utilizing this code snippet within a functional component : return ( <div style={{ height: "700px", overflow: "auto" }}> <InfiniteScroll pageStart={0} loadMore={Fet ...

Issue with ng-repeat not updating in Meteor and Angular collaboration

(This is not one of those "Oh I forgot $scope.$apply()" problems) Question is: How can I achieve live binding with ng-repeat and a reactive helper function in the controller? Let's focus on the code: index.js: <body ng-controller="AppCtrl as ap ...

Select an item, then toggle classes on the other items to add or remove them

My code includes the following HTML elements: <ul> <li class="one"><a href="#">one</a></li> <li class="two"><a href="#">two</a></li> <li class="three"><a href="#">three</a>&l ...

What is the best way to display user input within a paragraph using React?

I've been working on a To-Do list and I have successfully implemented the functionality to add new tasks. The issue I'm facing is that when I try to add a task, it doesn't show up in the paragraph within my Todo component, even though I can ...

What methods can be employed to restrict a device from accessing a page in a React application?

In the process of developing a form manager similar to Google Forms, I am faced with the task of preventing users from submitting the same form multiple times. One approach I am considering is using the user's device IP address to redirect them to a " ...