我在问自己React.memo是否与重组pure()完全相同...
fetch("url", {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/x-www-form-urlencoded",
"Content-Length": "data.length"
},
body: JSON.stringify({ api: "checkOtp", otp: "235656" })
})
.then(response => response.json())
.then(responsejson => {
this.setState({
isLoading: false,
dataSource: responsejson.code
});
})
.catch(err => {
console.log(err);
});
或
import { pure } from 'recompose';
export default pure(MyComp);
有什么想法吗?
答案 0 :(得分:0)
React.memo is a higher order component. It’s similar to React.PureComponent but for function components instead of classes.
因此它们并非完全相同,但它们具有相同的目的。