forked from ppfun/pixelplanet
fix some react errors
This commit is contained in:
parent
4dca37e67a
commit
4182f1a6e3
|
@ -54,7 +54,7 @@ const Captcha = ({ autoload, width }) => {
|
||||||
setCaptchaData({ url: svgUrl, id: captchaid });
|
setCaptchaData({ url: svgUrl, id: captchaid });
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(async () => {
|
useEffect(() => {
|
||||||
if (autoload) {
|
if (autoload) {
|
||||||
reloadCaptcha();
|
reloadCaptcha();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,16 +16,19 @@ function getUserFromUrl(url) {
|
||||||
const TikTok = ({ url }) => {
|
const TikTok = ({ url }) => {
|
||||||
const [embedCode, setEmbedCode] = useState(null);
|
const [embedCode, setEmbedCode] = useState(null);
|
||||||
|
|
||||||
useEffect(async () => {
|
useEffect(() => {
|
||||||
const prot = window.location.protocol.startsWith('http')
|
async function fetchData() {
|
||||||
? window.location.protocol : 'https';
|
const prot = window.location.protocol.startsWith('http')
|
||||||
// eslint-disable-next-line max-len
|
? window.location.protocol : 'https';
|
||||||
const tkurl = `${prot}//www.tiktok.com/oembed?url=${encodeURIComponent(url)}`;
|
// eslint-disable-next-line max-len
|
||||||
const resp = await fetch(tkurl);
|
const tkurl = `${prot}//www.tiktok.com/oembed?url=${encodeURIComponent(url)}`;
|
||||||
const embedData = await resp.json();
|
const resp = await fetch(tkurl);
|
||||||
if (embedData.html) {
|
const embedData = await resp.json();
|
||||||
setEmbedCode(embedData.html);
|
if (embedData.html) {
|
||||||
|
setEmbedCode(embedData.html);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
fetchData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
if (!embedCode) {
|
if (!embedCode) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user