+
80
-

useRef is not defined

我把react不在script内import,放到外面就报错

<script  type="module">
import React, { useEffect, useRef, useState } from 'https://cdn.skypack.dev/react@17';
</script>

上面不报错,但是改成下面这样就报错了

<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/react.production.17.1.js"></script>

请问怎么办?

网友回复

+
0
-

改成这样

<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/react.production.17.1.js"></script>
<script>
 const {useEffect, useRef, useState } = React;
</script>

我知道答案,我要回答