score:0
can you try this one i think you forgot the data key in your response, but i can't be sure as i don't have getresponse() function?
import react from 'react';
import getresponse from '../handler/getresponse.jsx';
import spinner from '../spinner/spinner.jsx';
import './modal.css';
const modal = ({close, item}) => {
const r = getresponse(item);
const response = r.data;
console.log(response);
// you can check if it is string with this one;
if (typeof response.image === 'string' && response.image !== '') {
console.log('string exists and is not empty')
}
return (
<div>
{response === null &&(<spinner/>)}
{response &&(
<div classname='modal'>
<div classname='popup'>
<h1>{response.result.name}</h1>
<h5>{response.result.description}</h5>
{(response.image === "error") &&(
<p classname="text">{response.result.detaileddescription.articlebody}</p>
)}
{response.image && (response.image !== "error") &&(
<div classname="container">
<div classname="left">{response.result.detaileddescription.articlebody}</div>
<div classname="right"><img classname="image" alt="image" src={response.image}/></div>
</div>
)}
{response.result.image &&(
<div classname="container">
<div classname="left">{response.result.detaileddescription.articlebody}</div>
<div classname="right"><img classname="image" alt="image" src={response.result.image.contenturl}/></div>
</div>
)}
<button onclick={ () => { close(false) }}>close me</button>
</div>
</div>
)}
</div>
);
}
export default modal;
Source: stackoverflow.com
Related Query
- React - how to check if a specific field value of an object array contains certain string?
- How to check if object contains a string value?
- How to check if array of objects that contains another array of object has property
- How to get a config value into a href as string instead of object object
- How to check two arrays of object has the same property value or not?
- How to check if an Array with Object contains a Property
- how to check if string contains number with react
- How to check If the value of an input is number or string in react js?
- How can I instantiate an object based on a string value
- In React how to make input check box ticked based on object value
- How to check and return value of state object array and use that to identify which object to take data from
- how to filter through an array and check if a nested object includes a value of true using reselect in redux
- How can I check if an object has an empty value on a key?
- How to check if a value in an array is present in other object and accordingly return a new object
- React useState: object as state, how to update a string value by replacing and avoid cancat?
- How get items in object which contains in nested array given value
- How to split a long string into a multi-line string, but the string is a value inside of a javascript object
- How to check one of my object value is empty or not
- How to loop over an object in an array of JSON data and check if their name contains a certain string?
- Typescript: How to add type check for history object in React?
- How to query by text string which contains html tags using React Testing Library?
- React Hooks - How to get parameter value from query string
- How to convert moment date to a string and remove the moment object
- How to do POST in FORM Submit using reactjs and pass the object value into REST service?
- How to convert object to string in react js
- How to pass an object value in a form's select field onChange (using React, without Redux)
- How to generate query string from a nested object
- React How to fix Failed prop type - Invalid prop of type string expected object
- How can I interpolate a Animated value to result into a boolean or a string in react-native?
- Yup validate array of objects contains at most one object where property = value
More Query from same tag
- How to stick an element to the top coming from above on scrolling?
- Need clarification for react + react-redux hooks + middleware thunk+ fetching API
- How to stop TypeScript error 'Type A has no properties in common with Type B' when Type B "extends" Type A in some way
- React conditional attribute
- React Google Maps Unable to set scroll zoom off
- Implement lazy loading in nested routes
- How can i store the Ant Design's Time Picker time?
- how to customize the Facebook Login Button with ReactJs
- How to run start React Error0308010C
- Is there a benefit in React useEffect to resolving promises like this?
- Firing React Apollo mutation on page load
- Axios NTLM doesn't work on POST (but work with GET)
- How to descturcture an object in Typescript when properties are optional?
- CSS class not applying when using SASS in Webpack(5)/React project with Typescript
- ModalTrigger not found but the Modal component is?
- Where to add signup button in a form in reactjs?
- Change the borderBottom styling of the TextField, when disabled, to 'none'?
- Change state with dropdown reactstrap
- Filter multiple values in React
- How to send the position on a board from a Board to a Cell component in React JS using nested array.map
- React App: Cannot find module 'react-dom/client' or its corresponding type declarations
- How to concatenate a new item with hooks in react js?
- "Multipart/form-data" is not woking in React-redux form upload
- React. Basic example of re-rendering using react-router. +100 rep
- How do I restrict the db fields stored in a material-ui Autocomplete component in a React + Meteor Project?
- react-scripts build an unminified version
- How can I get the value of an input from a button click event?
- React JS passing data from firebase into props for my component
- Axios, UseEffect, Redux
- Datetime format sorting issue in Reactjs