小编nor*_*ial的帖子

错误:在 TCPConnectWrap.afterConnect [as oncomplete] 连接 ETIMEDOUT

我正在尝试使用 XMLHttpRequest 模块在 for 循环中异步调用 REST API。我在 1 个循环中发出 400 个请求,每 100 个请求后等待时间为 1 秒。这在客户端 JavaScript 上运行良好。但是,当我使用相同的模块在 NodeJS 上运行时(它不是本机可用的,我必须从 npmjs 下载),我在大约 230 个请求后收到此错误。知道我是否可以使用另一个模块来更好地处理这种批量 API 请求吗?

错误:在 TCPConnectWrap.afterConnect [as oncomplete] 连接 ETIMEDOUT

api rest node.js

5
推荐指数
1
解决办法
2万
查看次数

在 Azure 存储表中批量插入

我是使用 azure 存储表的新手。我试图批量插入我的实体,但我发现您无法执行具有不同分区键的批量操作。

有什么方法可以让我想在表格中插入大约 10,000 - 20,000 个文件详细信息。

这是我迄今为止尝试过的:

public class Manifest:TableEntity
{
    private string name;
    private string extension;
    private string filePath;
    private string relativePath;
    private string mD5HashCode;
    private string lastModifiedDate;

    public void AssignRowKey()
    {
        this.RowKey = relativePath.ToString();
    }
    public void AssignPartitionKey()
    {
        this.PartitionKey = mD5HashCode;
    }
    public string Name { get { return name; } set { name = value; } }
    public string Extension { get { return extension; } set { extension = value; } }
    public …
Run Code Online (Sandbox Code Playgroud)

c# azure azure-storage azure-table-storage azure-tablequery

4
推荐指数
1
解决办法
7379
查看次数

重新渲染过多。React限制了渲染次数以防止无限循环。-反钩

我对React这里的钩子不熟悉,我有一个侧边栏,我想将其更新为selecetedIndex为此选择的索引,ListItem即,当我选择一个项目时,我想更新selectedIdx为索引以显示选定的索引。我做错了。

      <ListItem button key={index}
                selected={selectedIdx===index} // to show selected need to update
                onclick={setSelectedIdx(index)}
              >
                  <ListItemIcon>{v.icon}</ListItemIcon>
                  <ListItemText primary={v.text} />
      </ListItem>


 let [selectedIdx,setSelectedIdx]=React.useState(0);
Run Code Online (Sandbox Code Playgroud)

这样我第二次尝试但没有结果:

         <ListItem button key={index}
                        selected={selectedIdx===index}
                        onclick={handleSelectedIdx(index)}
                      >
                          <ListItemIcon>{v.icon}</ListItemIcon>
                          <ListItemText primary={v.text} />
         </ListItem>

function handleSelectedIdx(i){
    setSelectedIdx(i)}
Run Code Online (Sandbox Code Playgroud)

我是新来的,我不知道该怎么做this.setState。失败的两种方式都可以让我知道是我错了。任何帮助表示赞赏。

更新:这里我不使用:

{()=>{handleDrawerToggle}}
Run Code Online (Sandbox Code Playgroud)

还是下面的作品为什么会这样呢?你能告诉我们吗?

<IconButton
        color="inherit"
        aria-label="Open drawer"
        edge="start"
        onClick={handleDrawerToggle}
        className={classes.menuButton}
      />

   function handleDrawerToggle() {
      setMobileOpen(!mobileOpen);  }

  const [mobileOpen, setMobileOpen] = React.useState(false);
Run Code Online (Sandbox Code Playgroud)

react-hooks

4
推荐指数
1
解决办法
3639
查看次数

迁移到 Material-ui v4,我收到 Modal 组件的警告

自从升级material-ui到 以来v4,我收到了一些 Modal 组件的警告。

例如

children失败的道具类型:提供给 的道具无效ForwardRef(Modal)

函数组件不能被指定引用。

这是模态代码(警告1):

import React from 'react';
import Proptypes from 'prop-types';
...

class DetailDialog extends React.Component {
  render() {
    const { classes, open, onClose } = this.props;

    return (
      <Dialog
        open={open}
      >
        ...
      </Dialog>
    );
  }
}

DetailDialog.propTypes = {
  open: Proptypes.bool,
  onClose: Proptypes.func,
};

export default DetailDialog;
Run Code Online (Sandbox Code Playgroud)

这是模态代码(警告2):

import React from 'react';
import PropTypes from 'prop-types';
...

class SelectCatDialog extends React.Component { …
Run Code Online (Sandbox Code Playgroud)

reactjs material-ui

4
推荐指数
2
解决办法
5730
查看次数

Gatsby,浏览器中无法访问环境变量

我想使用环境变量。我创建了.env.development文件并放置了一些变量。然后我包含dotenv插件来读取变量gatsby-config.js

require('dotenv').config({
    path: `.env.${process.env.NODE_ENV}`
});
Run Code Online (Sandbox Code Playgroud)

我的内容.env.development

GATSBY_APP=MYAPP
Run Code Online (Sandbox Code Playgroud)

它正在运行,gatbsy-node.js但在浏览器(REACT)中它是空的。我显示console.log(process.env)并返回空对象。

即使我安装和配置gatsby-plugin-env-variables.

browser process environment-variables reactjs gatsby

4
推荐指数
1
解决办法
2123
查看次数

Flutter - CheckboxListTile - 边框颜色白色

我不知道如何更改复选框边框的颜色并将文本移近。下面是我想要实现的代码和图像。

谢谢!

在此输入图像描述

CheckboxListTile(
                  title: const Text('Remember Me'),
                  value: _isSelected,
                  onChanged: (bool value) {
                    setState(() {
                      _isSelected = value;
                    });
                  },
                  controlAffinity: ListTileControlAffinity.leading,
                ),
Run Code Online (Sandbox Code Playgroud)

dart flutter

4
推荐指数
1
解决办法
6390
查看次数

如何更改 Tableview 的 UIContextualAction 的图像色调颜色?

我想改变图像的色调但无法改变,它总是返回白色。我已尝试渲染原始图像和模板图像,但仍然无法正常工作。

我在下面添加了屏幕截图:

我尝试改变它的颜色但没有成功

请任何人都可以帮助我

public func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {

    guard let cell = tableView.cellForRow(at: indexPath) as? DocumentListCell else {return UISwipeActionsConfiguration()}
    let likeAction = UIContextualAction(style: .normal, title:  "", handler: { (ac:UIContextualAction, view:UIView, success:(Bool) -> Void) in
        print("likeAction ...")
        success(true)

    })

    likeAction.image = #imageLiteral(resourceName: "Favourite_Selected")
    likeAction.backgroundColor = UIColor.init(red: 239/255, green: 239/255, blue: 239/255, alpha: 1)

    let downloadAction = UIContextualAction(style: .normal, title:  "", handler: { (ac:UIContextualAction, view:UIView, success:(Bool) -> Void) in
        print("Trash action ...")
    })
    downloadAction.backgroundColor = UIColor.red//UIColor.init(red: …
Run Code Online (Sandbox Code Playgroud)

tableview swipe swift

4
推荐指数
1
解决办法
2632
查看次数

如何使用currying在React中创建HoC并同时连接到Redux存储?

我将React和Redux与结合使用react-redux,并且在React中创建了一个我想连接到Redux存储的高阶组件,如下所示:

const HoC = parameter => WrappedComponent => 
    return class WithSelected extends Component {

    // ..some use of 'parameter'

    render() { 

         return <WrappedComponent />

     }

  [...]

  const exportComponent = compose(
      connect(mapStateToProps),
      HoC
   )

 export default exportComponent;
Run Code Online (Sandbox Code Playgroud)

import Component from '../Component'
import exportComponent from '../file'

const componentToExport = exportComponent('someValue')(Component);
Run Code Online (Sandbox Code Playgroud)

现在,这种方法会产生以下错误:

TypeError:Object(...)不是一个函数

顺便说一句,如果我不使用currying创建Hoc,它的工作原理如下:

const HoC = (parameter, WrappedComponent)  => [etc]
Run Code Online (Sandbox Code Playgroud)

import Component from '../Component'
import exportComponent from '../file'

const componentToExport = exportComponent('someValue', Component);
Run Code Online (Sandbox Code Playgroud)

有用。但是我该如何在React中使用currying创建HoC并同时使用Redux?

currying reactjs react-redux

4
推荐指数
1
解决办法
42
查看次数

React Material UI:“主题”未定义 no-undef

我正在使用 Material-ui 创建一个简单的 React 应用程序。我正在使用 MuiThemeProvider 和 ThemeProvider 作为主题。

应用程序.js

import React from 'react';
import { createMuiTheme,  MuiThemeProvider } from '@material-ui/core/styles';
import { ThemeProvider } from '@material-ui/styles';
import { CssBaseline } from '@material-ui/core';
import { Topic } from './dashboard/components/drawer/topic.js' 

const theme = createMuiTheme({
    palette : {
        type : 'dark',
        background : {
            default : "#000000"
        },
        secondary : {
            main : '#E19A4C'
        }
    }
})

function App() {
    return (
        < MuiThemeProvider theme={theme}>
            <ThemeProvider theme={theme}>
                <CssBaseline />
                <div className="App">
                    <Dashboard …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs material-ui react-hooks

4
推荐指数
1
解决办法
2万
查看次数

关闭并重新打开选项卡时 Flutter web shared_preferences 不可用

Flutter web 现在支持 shared_preferences。我已经添加shared_preferences到我的颤振网络应用程序中。我的问题是当我设置首选项时,比如当我启动应用程序时,它在应用程序的任何地方都可以正常工作,但是当我关闭浏览器并再次启动应用程序并尝试检索它时,它什么都不返回。如何在关闭并启动应用程序后使其工作。

_showPref()async{
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setInt("myKey", 98);
}

@override
  void initState() {
    // TODO: implement initState
    super.initState();
    _showPref();
  }    

// then retrieve with the code
getPrefs(){
   SharedPreferences prefs = await SharedPreferences.getInstance();   
   int count = (prefs.getInt("myKey")??0);
   print(" 2. new prefs: $count");
}
Run Code Online (Sandbox Code Playgroud)

dart flutter flutter-web

3
推荐指数
1
解决办法
635
查看次数