React Image Slider not loading pictures

Can someone help me troubleshoot why my images are not displaying in the slider on my homepage? I have set up the slider using React Slideshow Image, but the images are not showing up for some reason.

I am also wondering if anyone knows of any full-screen slider libraries that would work well for displaying background images on a homepage?

Below is a snippet of the code I am currently using:

import React from 'react'
import { Fade } from 'react-slideshow-image'
import * as styles from '../styles/slider.module.css'
import 'react-slideshow-image/dist/styles.css'

const fadeImages = [
  'src/images/constructionconcrete.jpg',
  'src/images/constructionbuilding.jpg',
  'src/images/constructiondusk.jpg'
];

const ImageSlider = () => {
  return (
    <div className={styles.imageContainer}>
      <Fade>
        <div className={styles.eachFade}>
          <div>
            <img src={fadeImages[0]} />
          </div>
          <p>First Image</p>
        </div>
        <div className={styles.eachFade}>
          <p>Second Image</p>
          <div>
            <img src={fadeImages[1]} />
          </div>
        </div>
        <div className={styles.eachFade}>
          <div>
            <img src={fadeImages[2]} />
          </div>
          <p>Third Image</p>
        </div>
      </Fade>
    </div>
  );
};

export default ImageSlider;

If anyone has any insights or suggestions, I would greatly appreciate it!

Thank you in advance!

Answer №1

Seems like the image URLs are not linked correctly within this document's directory. Consider using relative paths, such as going two folders up it would be ../../images/whatever

If that doesn't solve it, another suggestion could be that the divs or other elements lack visible dimensions, so adjusting their width and height might help.

Answer №2

Experiment by relocating your pictures directory inside the open folder and update the image URL list to have each string in the form of "pictures/first.jpg"

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

Responsive div not displaying background image

Here is a straightforward and easy-to-understand code snippet: HTML markup: <div class="jumbotron text-center top-jumbotron"> </div> CSS: .top-jumbotron { background: #ffcc00; background-image: url('../../bootstrap/img/home-pag ...

Reduce the amount of times append is used in JQuery

Whenever I click the button in Jquery, I aim to limit the number of appends that occur. function standardRoom() { var counter = 0; if ($('select#selectBoxStandard option').length > 1) { counter++; $('#selectBoxStandard&ap ...

Differentiating onClick events for parent and child elements

I need help with my JSX code: <div id="parent" onClick={clickOnParent} style={{ width: 100, height: 100 }}> <div id="child" onClick={clickOnChild} style={{ width: 20, height: 20 }} /> </div> When I click on the pare ...

Which specific transitionend (or animationend) event should I use for this application?

I'm feeling a bit lost when it comes to using transitionend (or if I should be using animationend in this scenario). I'm not sure whether to utilize var, node, or box. Essentially, I am a complete beginner in this case. My goal is to have my div ...

Having trouble interpreting PHP-generated JSON data in JavaScript

I have a PHP script that outputs a JSON string. <?php $arr = array( 'id' => '1', 'myarray' => array( array('a' => 'a1', 'b' => 'b1', 'c' => 'c1', & ...

Troubleshooting problem with rotation and text geometry label on AxisHelper

Within my main scene, there is a sphere along with a subwindow located in the bottom right corner where I have displayed the (x,y,z) axis of the main scene. In this specific subwindow, I am aiming to label each axis as "X", "Y", and "Z" at the end of each ...

Implementing a custom theme for React material-table

I am currently working on integrating react material-table (https://github.com/mbrn/material-table) with my project. My goal is to customize the styling and theme of the table. Here's an example of what I've tried: <MaterialTable options={ ...

function complete, ajax request finished

When working with Ajax to get data, I encountered a situation where I needed to return the value of `username` from within an if statement that is inside a loop and a function. How can I achieve this? Your help would be appreciated. $.ajax({ ...

Which symbol is preferable to use in JS imports for Vue.js/Nuxt.js - the @ symbol or the ~ symbol?

I am seeking guidance on a matter that I have not been able to find a clear answer to. Webapck typically uses the ~ symbol as an alias for the root directory. However, I have noticed that some developers use the @ symbol when importing modules using ES6 s ...

"Exploring JSON data with jQuery: A guide to efficient search techniques

I have a local file containing JSON data which I successfully loaded using jQuery. My current task is to specifically find the pId with the value of "foo1". The JSON data { "1":{ "id": "one", "pId": "foo1", "cId": "bar1" }, "2":{ ...

Dynamic resizing in NextJs does not trigger a re-render

My goal is to dynamically pass the width value to a component's styles. Everything works fine on initial load, but when I resize the window, the component fails to re-render even though the hook is functioning as intended. I came across some informat ...

In order to verify the dynamic components within the table

I need assistance with validating dynamically created textareas. In the code below, I am able to validate only the first row but struggling to do so for the second row. How can I get all the row values validated? Thank you in advance. To generate dynamic ...

Utilizing various colors for tooltipFontColor in Chart.js

I'm trying to customize the font color for tooltip labels in Chart.js, but I want to set different colors based on certain conditions. Specifically, I want the label color to be white by default, but change to red if a condition is met. I've look ...

Steps to selectively enable or disable checkboxes in a dynamic table depending on a dropdown selection

I'm currently facing an issue with a dynamically generated HTML table from a JSON file. Each row in the table consists of a dropdown list and a checkbox. I need the checkbox to be disabled when the default value is selected in the dropdown, and enable ...

In Angular, the ng-click directive that assigns the value of tab to $index does not seem to be functioning properly

I encountered an issue within my app <li ng-repeat="name in tabs track by $index" ng-class="{selected: tab==$index}" ng-click="tab = $index">{{name}}</li> After clicking on each item, the selected class remains enabled and switching to anothe ...

Sketch a straight path starting from the coordinates x,y at a specified angle and length

Is there a way to draw a line in Javascript starting from a specific x/y position with a given length and angle, without having to define two separate points? I have the x/y origin, angle, and length available. The line should be placed on top of a regula ...

Arrange three images both vertically and horizontally at the center of the page

I am facing an issue with aligning a button and 2 images in a row on my website. Currently, this is how it looks: https://i.stack.imgur.com/yrQB6.png Here is the HTML code I am using: <div class="row text-center"> <div class="col-md-12"> ...

Creating a WebExtension using Angular and TypeScript

I am currently working on creating a WebExtension using Angular and Ionic. The extension successfully loads the application and enables communication between Content Script and Background Script. However, I am facing an issue where the TypeScript code is n ...

ajax ignores output from php

I've been working on passing PHP echo values through AJAX, but I've encountered a problem where the if and else conditions are being skipped in the success function of AJAX. Even when the if condition is met, the else statements are still being e ...

Exploring the world of handling GET and POST parameters in Node.js with

As someone who is new to Node/Express, I've noticed that GET parameters can be captured using the following syntax: app.get('/log/:name', api.logfunc); For POST requests, it can be done like this: app.post('/log', ... (with for ...