小编Sar*_*Vin的帖子

React Native - __DEV__未定义

我有一个react-native@0.26.2项目.我删除了node_modules文件夹,并在我给出以下命令后:

npm i
react-native upgrade
Run Code Online (Sandbox Code Playgroud)

但我得到这个错误:

react-native.js:15 

ReferenceError: __DEV__ is not defined
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

npm reactjs react-native

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

将 efs 卷添加到 ecs fargate

我想将 EFS 与 fargate 一起使用,但在任务开始时出现此错误:

ResourceInitializationError: failed to invoke EFS utils commands to set up EFS volumes: stderr: Failed to resolve "fs-xxxxx.efs.eu-west-1.amazonaws.com" - check that your file system ID is correct
Run Code Online (Sandbox Code Playgroud)

我已经检查了文件系统 ID,它是正确的...我如何获得有关此错误的更多信息?它可能与安全组有关吗?

这是我与 terraform 一起使用的代码,我为两个可用区使用了两个挂载点:

resource "aws_efs_file_system" "efs_apache" {
}

resource "aws_efs_mount_target" "efs-mount" {
  count                     = 2

  file_system_id            = aws_efs_file_system.efs_apache.id
  subnet_id                 = sort(var.subnet_ids)[count.index]
  security_groups           = [aws_security_group.efs.id]
}

resource "aws_efs_access_point" "efs-access-point" {
  file_system_id = aws_efs_file_system.efs_apache.id
}

resource "aws_security_group" "efs" {
  name        = "${var.name}-efs-sg"
  description = "Allow traffic from self"
  vpc_id …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services terraform amazon-efs aws-fargate terraform-provider-aws

9
推荐指数
1
解决办法
867
查看次数

开玩笑-从'setup.js'中找不到模块'setupDevtools'

我正在研究Jest,并且尝试将其添加到我的组件=> github.com/bolket/react-native-scrollview-smart中。

当我开始测试时,出现以下错误:

$ jest 
 FAIL  lib/ScrollViewSmart.test.js
  ? Test suite failed to run

    Cannot find module 'setupDevtools' from 'setup.js'

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:179:17)
      at Object.<anonymous> (node_modules/react-native/jest/setup.js:30:1)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.492s
Run Code Online (Sandbox Code Playgroud)

经过多次尝试,我将测试移至__DEV__文件夹中,并且错误已解决。

但是,如果我再次运行测试,我将再次出现错误...。

你能告诉我什么地方错了吗?

jestjs react-native

8
推荐指数
1
解决办法
3503
查看次数

从使用 firebase-admin 上传的文件中获取公共 URL

我使用 firebase-admin 和 firebase-functions 在 Firebase 存储中上传文件。

我在存储中有这个规则:

service firebase.storage {
  match /b/{bucket}/o {
    match /images {
      allow read;
      allow write: if false;
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我想使用以下代码获取公共 URL:

const config = functions.config().firebase;
const firebase = admin.initializeApp(config);
const bucketRef = firebase.storage();

server.post('/upload', async (req, res) => {

  // UPLOAD FILE

  await stream.on('finish', async () => {
        const fileUrl = bucketRef
          .child(`images/${fileName}`)
          .getDownloadUrl()
          .getResult();
        return res.status(200).send(fileUrl);
      });
});
Run Code Online (Sandbox Code Playgroud)

但我有这个错误.child is not a function。如何使用 firebase-admin 获取文件的公共 url?

google-cloud-storage firebase firebase-storage firebase-admin

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

JSX的ESLint配置

我想配置ESLint来检查我的JSX文件,但我的配置不起作用.这是正确的方法吗?

.eslintrc.js:

module.exports = {
  extends: 'airbnb',
  parserOptions: {
    ecmaFeatures: {
      jsx: true
    }
  },
  plugins: [
    'react',
  ],
  parser: 'babel-eslint'
};
Run Code Online (Sandbox Code Playgroud)

jsx reactjs eslint react-jsx

7
推荐指数
3
解决办法
7783
查看次数

如何使用 Firestore 规则检查字段是否存在?

我有一个包含产品集合和类别集合的 firestore 数据库。

仅当类别文档没有products字段时,我才希望向用户授予对类别集合的删除权限。

products 字段是一个引用数组。

我有这个规则:

match /shops/{shopId} {
  allow read: if true;
  allow write: if false;
  match /categories/{category=**}{      
    allow read: if true;
    allow write: if resource.data.products == null;
  }
}
Run Code Online (Sandbox Code Playgroud)

但是这个规则不起作用,我无法编写或更新文档。

firebase firebase-security google-cloud-firestore

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

无法在Cloud Functions for Firebase中获取根参考

还有另一种获取根参考的方法吗?

exports.orderUser = functions.database.ref('/orders/{shopId}/{orderId}').onWrite(event => {
    var eventSnapshot = event.data;
    // ...
    var rootRef = eventSnapshot.ref.parent.parent.parent; <== this line
    var userRef = rootRef.child(`/users/${user}/orders`);
});
Run Code Online (Sandbox Code Playgroud)

firebase google-cloud-functions

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

如何使用 golang 和 mongo-go-driver 在 mongodb 中创建文本索引?

我正在尝试对集合进行全文搜索,但为了做到这一点,我需要创建一个文本索引。如何在两个字段上创建文本索引?

我知道我必须使用这样的东西:

opts := options.CreateIndexes().SetMaxTime(10 * time.Second)

idxFiles := []mongo.IndexModel{
    {
      Keys: bsonx.Doc{{"name": "text"}},
    },
  }

db.Collection("mycollection").Indexes().CreateMany(context, idx, opts)
Run Code Online (Sandbox Code Playgroud)

go mongodb

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

在 react-native 中滚动时修复了导航栏

我有 android 和滚动视图的问题。我想在软键盘打开时看到文本输入。

所以我使用这个组件 => https://github.com/sarovin/react-native-scrollview-smart

但问题是导航栏没有固定在顶部而是消失了......

错误的 Gif

导航栏是 react-native-router-flux => https://github.com/aksonov/react-native-router-flux 的一个组件

有什么建议吗?

谢谢

android react-native

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