How to display the fetched json from redux in my react component?
Date : March 29 2020, 07:55 AM
I wish this helpful for you You can use connect from react-redux to get the content of react-redux state and pass them as props in the react component import React from 'react';
import _ from 'lodash';
import {connect} from 'react-redux';
class Poems extends React.Component {
render(){
return (
<div>
//poems from state will be passed as props to this component
{_.map(this.props.poems, poem => {
return (
<div>
<div>{poem.title}</div>
<div>{poem.text}</div>
</div>
)}
</div>
);
}
}
const mapStateToProps = (state) => ({
poems: getPoems(state); //method to get poems from redux state
});
export default connect(mapStateToProps)(Poems);
|
Angular 6 display image fetched from AWS S3
Date : March 29 2020, 07:55 AM
wish helps you The problem is, that you used invalid Parameters to your API calls - the SDK doesn't know what to do with region, accessKeyId and secretAccessKey: const params = {
Bucket: 'asdasd',
region: 'asadas1', // Here,
accessKeyId: 'SADIYIUYSADSA8768GHSAD', // here
secretAccessKey: 'sdas+sadJSADH7', // and here
}
AWS.config.update({
region: 'us-east-1',
accessKeyId: "Don't do this",
secretAccessKey: "It's a terrible idea!"
});
|
How to display a particular clicked image from multiple image fetched from database using while loop in php, and javascr
Date : March 29 2020, 07:55 AM
it helps some times I haven't tested this, since i haven't got a PHP setup running. But I think one way to solve this, could be something like this: <!DOCTYPE html>
<html>
<head>
<title>Home</title>
<link rel = "stylesheet" type = "text/css" href = "accounts.css">
</head>
<body>
<?php
$servername = 'localhost';
$user = 'root';
$passwords = 'root';
$dbname = 'project';
$conn = new mysqli($servername, $user, $passwords, $dbname);
if($conn->connect_error)
{
die("Could not connect... ".$conn->connect_error);
}
$sql = "SELECT photo_url FROM photo WHERE username = '$username'";
$result = $conn->query($sql);
if($result->num_rows > 0)
{
$i=0;
while($row = $result->fetch_assoc())
{
$i++;
echo "<span id = 'photos'>";
echo "<img onClick='showImage(" . $i . ")' id = 'myProfile" . $i . "' src = '".$row['photo_url']."' alt = 'photo' width = 190px' height = '200px' style = 'border: 1px solid #aaaaaa;'>";
echo "</span>";
echo "<div id = 'popUp" . $i . "' class = 'pop1'>";
echo "<span class = 'close1' onClick='closeImage(" . $i . ")'>×</span>";
echo "<img class = 'pop-content' id = 'img" . $i . "'>";
echo "</div>";
}
}
else
{
echo "<p>You haven't uploaded any photo.</p>";
}
$conn->close();
?>
<script>
function showImage(intId) {
var pop1 = document.getElementById('popUp'+intId);
var img1 = document.getElementById('myProfile'+intId);
var popImg1 = document.getElementById('img'+intId);
pop1.style.display = 'block';
popImg1.src = img1.src;
}
function closeImage(intId) {
var pop1 = document.getElementById('popUp'+intId);
pop1.style.display = 'none';
}
</script>
</body>
</html>
|
How to display fetched data in react native
Date : March 29 2020, 07:55 AM
it fixes the issue Flatlist data property expects an array. But you seem to set an object. state = {
items:[]
}
display() {
fetch('myUrl', { method: 'GET'})
.then((response) => response.json())
.then((responseJson) => {
console.log(responseJson);
this.setState({
items: responseJson
})
})
.catch((error) => {
console.error(error);
});
}
<View>
<FlatList
data={this.state.items}
renderItem={({item}) => <Text key={item._id}>{item.title}</Text>}
keyExtractor={ item => item._id}
/>
</View>
|
SAP B1, How to display fetched Image from ItemImage?
Date : September 01 2020, 10:00 AM
To fix the issue you can do If you want to use images dynamically, you have to fetch the images as soon as the component is mounted and insert it afterwards. The fetched picture should then be saved in the state of the component and included from there in the src attrbut of the img tag. Assuming you can already fetch the picture, the code below should work. import React, { Component } from "react";
export default class ComponentWithFetchedImage extends Component {
constructor() {
super();
this.state = { image: undefined };
}
componentDidMount() {
let fetch_url = "https://picsum.photos/200"; // Insert your fetch url here
fetch(fetch_url)
.then(res => res.blob())
.then(blob => URL.createObjectURL(blob))
.then(url => this.setState({ image: url }))
.catch(err => console.log(err));
}
render() {
return (
<div className="component">
<img src={this.state.image} alt="" />
</div>
);
}
}
|