Answer the question
In order to leave comments, you need to log in
Re-rendering a React component?
Good afternoon, help me understand how can I make the component rerender with a new link
const block = ({url}) => {
const [loading, setLoading] = useState(true);
const [data, setData]:any = useState();
useEffect(() => {
if (loading && url !== null) {
axios.get(url, { responseType: 'blob' }).then(response => {
setData(window.URL.createObjectURL(response.data));
setLoading(false);
});
}
return () => {};
});
return loading ? (
<div
style={{
width: '100%',
height: '160px',
display: 'grid',
alignItems: 'center',
justifyContent: 'center'
}}
>
<FontAwesomeIcon
style={{ fontSize: 20 }}
spin
icon={faSpinner}
/>
</div>
) : (
<div style={{ width: '100%', height: 160 }}>
<img
style={{
objectFit: 'contain',
objectPosition: 'center',
maxWidth: '100%',
maxHeight: '100%'
}}
width="100%"
height="auto"
src={data}
/>
</div>
);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question