小编Dan*_*iel的帖子

@react-native-community/react-native-device-info:NativeModule.RNDeviceInfo 为空

我最近进行了一个react-native initand when I ranreact-native run-ios`我得到了这个错误:

在此输入图像描述

现在你的第一反应是说我一定已经安装了它并且没有链接它......不是这样,这是我的package.json文件:

{
  "name": "NFIBEngage",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "react": "16.8.6",
    "react-native": "0.60.4"
  },
  "devDependencies": {
    "@babel/core": "7.5.5",
    "@babel/runtime": "7.5.5",
    "@react-native-community/eslint-config": "0.0.5",
    "babel-jest": "24.8.0",
    "eslint": "6.1.0",
    "jest": "24.8.0",
    "metro-react-native-babel-preset": "0.55.0",
    "react-test-renderer": "16.8.6"
  },
  "jest": {
    "preset": "react-native"
  }
}
Run Code Online (Sandbox Code Playgroud)

样板文件

所以我想好吧,所以让我尝试一下react-native link react-native-device-info,果然我收到了以下错误消息:

error Unknown dependency. Make sure that the package you are trying to …
Run Code Online (Sandbox Code Playgroud)

reactjs react-native

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

为什么密码会出现在 url 上?

我已经使用 Eleventy 开发了一些表单,我从来没有遇到将凭据附加到 URL 的任何问题,但是现在我制作了一个新的密码身份验证表单,这个表单将密码附加到 url,我不清楚为什么。

这是 Eleventy 的形式:

module.exports = function() {
  return `
    <form class="rds-form">
     <div>
      <input
        type="password"
        id="input_password"
        name="Password"
        aria-required="true"
        class="form-control to-switch"
        maxlength="32"
        data-required-message="A password is required to login. Please add it now"
      / >
      </div>
      <div class="pull-right">
       <button
         type="submit"
         class="btn btn-primary btn-lg submit-btn"
         id="custom-password"
        >
        Login
        </button> 
      </div>
    </form>
  `
}
Run Code Online (Sandbox Code Playgroud)

它的逻辑:

document.querySelector('.rds-form').addEventListener('submit', function () {
 alert('form submitted!');
});
Run Code Online (Sandbox Code Playgroud)

javascript

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

未定义错误“propTypes”且未定义错误“defaultProps”

我正在处理react-redux应用程序的一些可访问性问题。

我安装了npm install eslint eslint-plugin-jsx-a11y@4.0.0 --save-dev,现在当我运行我的应用程序时,出现以下错误:

Failed to compile.

Error in ./src/components/Promo.jsx

/code/src/components/Promo.jsx
  15:10  error  'propTypes' is not defined       no-undef
  19:10  error  'defaultProps' is not defined    no-undef
  42:3   error  'updateCellCode' is not defined  no-undef

? 3 problems (3 errors, 0 warnings)
Run Code Online (Sandbox Code Playgroud)

我没有看到任何语法错误,代码对我来说看起来很正确:

import React, { PureComponent, PropTypes } from 'react';
import { throttle, prepAndFormatForInnerHTML } from '../util';
import '../assets/styles/application/promo.css';
import Promos from '../assets/strings/promos.json'; // placeholder info

const MOBILE_BREAKPOINT = 679; // from scss file

/** Used …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs eslint react-proptypes

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

AssertionError [ERR_ASSERTION]: 必须指定任务函数

我正在尝试重构我 2 年前编写的一些遗留代码。gulpfile.js准确地说是一个文件。

问题似乎在这里:

// gulp.task('default', ['browserify', 'copy'], function() {
//   return gulp.watch('src/**/*.*', ['browserify', 'copy']);
// });
Run Code Online (Sandbox Code Playgroud)

我将其注释掉并替换为:

gulp.task('default', gulp.series('browserify', 'copy'), function() {
  return gulp.watch('src/**/*.*', ['browserify', 'copy']);
});
Run Code Online (Sandbox Code Playgroud)

还不够好。整个文件如下所示:

var gulp = require('gulp');
var browserify = require('browserify');
var reactify = require('reactify'); // Converts jsx to js
var source = require('vinyl-source-stream'); // Converts string to a stream

gulp.task('browserify', function() {
  browserify('./src/js/main.js')
    .transform('reactify')
    .bundle()
    .pipe(source('main.js'))
    .pipe(gulp.dest('dist/js'));
});

gulp.task('copy', function() {
  gulp.src('src/index.html').pipe(gulp.dest('dist'));
  gulp.src('src/css/*.*').pipe(gulp.dest('dist/css'));
  gulp.src('src/images/*.*').pipe(gulp.dest('dist/images'));
  gulp.src('src/js/vendors/*.*').pipe(gulp.dest('dist/js'));
});

// gulp.task('default', ['browserify', 'copy'], function() …
Run Code Online (Sandbox Code Playgroud)

javascript gulp

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

如何将我的项目导出为git存储库的.zip?

最近有人要求.zip我将我的项目之一导出到我的Git存储库中。

实际上,在我使用Git的4年中,我从来没有这样做。

我希望所有在命令行终端中完成的答案。

git zip export

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

Rust 相当于 Go 中的追加是什么?

我试图通过自己阅读文档来弄清楚,但对于如何将此 Go 函数转换为 Rust 没有运气:

func main() {
  cards := []string{"Ace of Diamonds", newCard()}
  cards = append(cards, "Six of Spades")

  fmt.Println(cards)
}

func newCard() string {
  return "Five of Diamonds"
}
Run Code Online (Sandbox Code Playgroud)

这是不正确的,至少我知道的 cards.append 是错误的:

fn main() {
    let mut cards: [&str; 2] = ["Ace of Diamonds", new_card()];
    let mut additional_card: [&str; 1] = ["Six of Spades"];
    cards.append(additional_card);

    println!("cards")
}

fn new_card() -> &'static str  {
    "Five of Diamonds"
}
Run Code Online (Sandbox Code Playgroud)

go rust

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

标签 统计

javascript ×3

reactjs ×2

eslint ×1

export ×1

git ×1

go ×1

gulp ×1

react-native ×1

react-proptypes ×1

rust ×1

zip ×1