'is it possible to custom the image size of dangerouslySetInnerHTML in react
I am using dangerouslySetInnerHTML to render some article html in react, now I am facing a problem that the image from html source stream was out of the page width, is it possible to resize the image size in dangerouslySetInnerHTML? or define the max width and height of dangerouslySetInnerHTML? this is my code :
import React from 'react';
import { useLocation} from 'react-router-dom';
import { ArticleDetailProps, connect, Dispatch, IArticleState, Loading } from 'umi';
const ArticleDetail: React.FC<ArticleDetailProps> = ({articles, dispatch, channelListLoading}) => {
const location = useLocation();
React.useEffect(()=>{
dispatch({
type: 'articles/getArticleDetail',
payload: (location as any).query.id
});
},[]);
let articleData = articles.article;
return (
<div>
<h2>{articleData.title}</h2>
<div style={{fontSize:'15px'}} dangerouslySetInnerHTML={{__html: articleData.content}} />
</div>
);
};
const mapStateToProps = ({articles, loading}: {articles: IArticleState, loading: Loading}) => {
return {
articles,
userListLoading: loading.models.articles
}
}
const mapDispatchToProps = (dispatch: Dispatch) => {
return {
dispatch
}
}
export default connect(mapStateToProps, mapDispatchToProps)(ArticleDetail);
Solution 1:[1]
I think you need to include the "order.click()" in the indented part of the code that check if the item is found in the list, like below.
text = ["Dog", "Cat", "Bird"]
for word in text:
try:
order = WebDriverWait(driver,5).until(EC.presence_of_element_located((By.XPATH, "//div/p[contains(text(),'{}')]".format(word))))
if order != None:
print(f"found div with word: {word}")
order.click()
break
except:
print(f"did NOT found div with word: {word}")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | CodeCupboard |
