Reactjs 如何连接;“网络速度”;图书馆;反应;?

Reactjs 如何连接;“网络速度”;图书馆;反应;?,reactjs,Reactjs,给出错误“URL不是构造函数” 我的代码 图书馆 从“React”导入React; const NetworkSpeed=require('network-speed'); const testNetworkSpeed=新的NetworkSpeed(); 异步函数getNetworkDownloadSpeed(){ 常量baseUrl=”http://eu.httpbin.org/stream-bytes/50000000"; const fileSizeInBytes=50000000; 常数

给出错误“URL不是构造函数”

我的代码

图书馆

从“React”导入React;
const NetworkSpeed=require('network-speed');
const testNetworkSpeed=新的NetworkSpeed();
异步函数getNetworkDownloadSpeed(){
常量baseUrl=”http://eu.httpbin.org/stream-bytes/50000000";
const fileSizeInBytes=50000000;
常数速度=等待测试网络速度。检查下载速度(
baseUrl,
文件大小字节
);
控制台日志(速度);
}
导出默认函数App(){
console.log(网络速度)
返回(
getNetworkDownloadSpeed()}>34
);
}

您不能将该软件包与React一起使用

它不是用于浏览器,而是用于Node.js()

import React from "react";

const NetworkSpeed = require('network-speed');
const testNetworkSpeed = new NetworkSpeed();

async function getNetworkDownloadSpeed() {
  const baseUrl = "http://eu.httpbin.org/stream-bytes/50000000";
  const fileSizeInBytes = 50000000;
  const speed = await testNetworkSpeed.checkDownloadSpeed(
    baseUrl,
    fileSizeInBytes
  );
  console.log(speed);
}

export default function App() {
  console.log(NetworkSpeed)
  return (
    <div className="App">
      <button onClick={() => getNetworkDownloadSpeed()}>34</button>
    </div>
  );
}