One of my methods involves extracting image links from pixabay and iterating over the array. While I am able to log them to the console, unfortunately they do not display properly within an

When working with image links from pixabay, I encountered an issue where the images were not displaying in the img tag even though they were successfully logged to the console. It's worth noting that I am using tailwind CSS for styling.

Here is the code snippet from App.js where I mapped over the array of images:

 <div className='flex relative h-1/2 w-1/2'>
        {images.map((image, i) => {
          console.log(image.webformatURL);
          <Image key={i} image={image.webformatURL} alt='aa' className='w-20 h-56' />

        })}
      </div>

And here is the Image component I attempted to use:

function Image({image}) {
  return (
    <div>
        <img src={image.webformatURL}/>
        {console.log(image.webformatURL)}
    </div>
  )
}

export  {Image}

Answer №1

Need to retrieve the tag

{pictures.map((picture, index) => {
  console.log(picture.webformatURL);
  return <Picture key={index} picture={picture.webformatURL} />
})}

Picture tag should look like this

function Picture({picture}) {
  return (
    <div>
      <img src={picture} alt='aa' className='w-20 h-56' /> 
    </div>
  )
}

export default Picture

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

Having issues with jQuery AJAX not functioning correctly in PHP environment?

Can someone explain how Ajax and jQuery work together? I'm new to both technologies and I want to use Ajax to delete a row in my index.php file. <head><link rel="stylesheet" type="text/css" href="css/style.css"></head> <h1&g ...

Issue with Material UI: The "styled" child component is failing to apply the specified CSS rules

I encountered a problem while trying to use the styled function to customize a React component, but for some reason, the styles are not being applied as expected. In the provided example, I anticipated that the Child component would be styled with color: r ...

Tips for locating the highest number in JavaScript

I'm having trouble with my code where the first number, even if it's the largest, is not displaying as such. Instead, it shows the second largest number. Even when following suggestions, I encountered an issue where if the numbers are entered as ...

Innovative approach for structuring tables with Awk

Below is a table in a specific format. Can an AWK script be created to reformat the table by excluding columns that only contain the number "1"? ST L1 L2 L3 L4 L5 ST2 1 1 1 1 1 ST2 1 0 1 0 1 ST3 1 0 1 0 1 ST3 0 0 1 1 1 ST4 1 0 1 0 1 ST5 1 0 1 0 1 ST6 1 0 ...

The problem with the Bootstrap Navbar Dropdown is that it opens up within the confines of

I have created a navigation bar using Bootstrap 4 and included the .navbar-bottom class to enable scrollbar functionality when there are more menu items than the total width of the page. However, an issue has arisen where the Bootstrap 4 navbar dropdown o ...

Unwrapping Promises in Angular for Seamless Resolution

I recently started working with Angular and found myself in a large project. I encountered a simplified version of my code below: var beforeClose = function() { var closeDeferred = $q.defer(), a = $q.defer(), b = $q.defer(), c = $q.defer() ...

Error: express is missing a closing parenthesis for the argument list

When running this code in the VS Code terminal, be sure to verify any errors that may occur. var express = require('express'); var app = express(); app.get('/', function(request, response) { response.send("hello world"); }); app.li ...

Implement a click event for the X-Axis label in Angular 2 Highcharts

I'm currently facing a challenge with hand-rolling a solution that involves adding a click listener to an X-Axis label in a column chart using the HighCharts API within an Angular 2+ application. Here is what I have gathered so far: I am utilizing ...

Signing in to a Discord.js account from a React application with Typescript

import React from 'react'; import User from './components/User'; import Discord, { Message } from 'discord.js' import background from './images/background.png'; import './App.css'; const App = () => { ...

What is the most efficient method for linking the hostname of my website to the file path within my Express.js static file server?

When using vanilla JavaScript in the browser, we can retrieve the hostname using: window.location.hostname However, if we are working with Node.js/Express.js on the server side, how can we achieve the same result? Furthermore, I am looking for a way to ...

Tips on effectively utilizing CSS sprites without a border on images

I am currently working on optimizing my website by using sprite images. The image I am using is in png format and looks like this: https://i.sstatic.net/pFhPq.png Here is a snippet of my CSS code: .bg-upperbar_1 { width: 55px; height: 55px; bac ...

What is the process for transmitting an array to a server using the POST method?

I am encountering an issue where the server is not receiving the arrays I am trying to send as parameters. The server should be able to receive two arrays named testAns and testQuest, but they seem to be missing on the server side. I'm unsure if the m ...

JavaScript - Updating array using provided arguments

I am working with numerous input elements that trigger a function when clicked, passing along various parameters containing information about the click event. For example: onClick="updateCart('product_id', 'product_name', 'produc ...

Tips for properly halting an AJAX request

My challenge is to halt an Ajax request when a user clicks a button. Despite using .abort(), the Ajax request continues to occur every 2 seconds. Essentially, the user waits for a response from the server. If the response is 2, then an Ajax request should ...

Retrieving Information from MongoDB Collection with Paginated Results in Universal Sorted Sequence

I'm in the process of working on a project that involves a MongoDB collection called words, which holds a variety of words. My objective is to retrieve these words in a paginated manner while ensuring they are globally sorted in lexicographical order. ...

Issue with ReactJS toggling radio button states not functioning as expected

I've encountered an issue with my code below where the radio buttons are not checking or unchecking when clicked. const Radio = props => { const { name } = props; return ( <div> <input id={name} type="radio" ...

Is array.push not functioning properly?

let teamMembers = []; response.team.members.forEach(async m => { let userResponse; try { userResponse = await axios.get(`https://api.hypixel.net/player?key=KEY&uuid=${m.uuid}`); } catch (err) { console.error(err); } ...

Exploring the Power of React and React-Native Refs

Can anyone guide me on how to enable the use of ref in my custom component? I'm a bit uncertain about the process. What would be the most effective approach? Here's an example of my component: <InputField ref="email" /> When I include a c ...

Utilizing AJAX within an Ember.RSVP.Promise

I'm curious about the necessity of using the "return" keyword in the common code snippet below when invoking AJAX requests. Specifically, is it necessary for the $.ajax function (considering that $.ajax already returns a promise), or does it serve ano ...

Adjust background-color to a specific percentage offset

I have a scenario where I am populating rows in a <table> using a foreach loop. However, I encounter an issue when trying to set a grey background for a cell based on a percentage calculated in PHP. For example, if the percentage is 50%, half of th ...