小编Dem*_*ims的帖子

尝试运行 React Native ios 应用程序时无法修复这 2 个错误

我在 React Native 环境中度过了一段糟糕的时光。在我一直工作的小初创公司从主分支拉取后,我无法开始npx react-native run-ios工作。我已经尝试了所有常见的嫌疑人,例如:

1. reinstall node modules from package.json
2. reinstall pod in /ios
3. reinstall cocoapods 
4. made sure to clear all caches
5. tried different versions of Node
6. reinstalled Node, NVM, Xcode, Cocoapods from the React-Native docs
7. made sure I have a .env file 
8. restarted my computer (you'd be surprised) 
Run Code Online (Sandbox Code Playgroud)

我得到的错误是:

Error: EISDIR: illegal operation on a directory, read
    at Object.readSync (fs.js:498:3)
    at tryReadSync (fs.js:332:20)
    at Object.readFileSync (fs.js:369:19)
    at UnableToResolveError.buildCodeFrameMessage …
Run Code Online (Sandbox Code Playgroud)

react-native

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

动态添加或删除react-hook-forms表单中的项目并注册输入?

我正在尝试实现一个相当复杂的表单,其中包含日期选择器和输入,用户可以添加多个(或删除)。然后,该数据将在提交时添加到整个表单中。我如何让react-hook-forms在真实表单中注册那个小动态人造表单?

这是人造表单输入:

          <AddPackagesStyle>
              <Label htmlFor="addedPackages" label="Add Packages" />

              <DatePicker
                id="dateRange"
                selected={startDate}
                selectsRange
                startDate={startDate}
                endDate={endDate}
                placeholderText="select dates"
                onChange={onDateChange}
              />
              <PackageInput
                id="PackageSelect"
                placeholder="Select Package"
                type="text"
                value={name}
                // @ts-ignore
                onChange={(e) =>
                  // @ts-ignore
                  setName(e.target.value)
                }
              />
              <ButtonContainer>
                <button type="button" onClick={clearAll}>
                  Clear
                </button>
                <button
                  type="button"
                  // @ts-ignore
                  onClick={addPackage}
                >
                  Add
                </button>
              </ButtonContainer>
            </AddPackagesStyle>
Run Code Online (Sandbox Code Playgroud)

这些条目被添加到 useState 挂钩中的数组中:

 const [addedPackages, setAddedPackages] = useState<any[]>([])
Run Code Online (Sandbox Code Playgroud)

然后这会在 JSX 中呈现为添加包:

 <ContentSubscriptionWrapper>
              {addedPackages.length !== 0 &&
                addedPackages.map((addedPackage, idx) => (
                  // @ts-ignore
                  <>
                    <ContentSubscriptionColumn>
                      {addedPackage.name && addedPackage.name}
                    </ContentSubscriptionColumn>
                    <ContentSubscriptionColumn>
                      {addedPackage.startDate && …
Run Code Online (Sandbox Code Playgroud)

forms onsubmit reactjs react-hook-form

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

Bootstrap Modal 在 Heroku 中使用 Rails 6 应用程序导致“未捕获的类型错误:无法将未定义或空值转换为对象”错误

我已经构建了一个 Rails 6 应用程序,它使用 React 作为前端并使用 Bootstrap React 作为我的样式组件。在本地一切正常,但是当我部署到 Heroku 并尝试创建“中断”时,它会引发以下错误:

Modal.js:21 Uncaught TypeError: Cannot convert undefined or null to object
    at hasOwnProperty (<anonymous>)
    at Modal.js:21
    at Array.forEach (<anonymous>)
    at Modal.js:20
    at t.n.render (Modal.js:302)
    at Qi (react-dom.production.min.js:4243)
    at Ji (react-dom.production.min.js:4234)
    at wc (react-dom.production.min.js:6676)
    at yu (react-dom.production.min.js:5650)
    at Mu (react-dom.production.min.js:5639)
Run Code Online (Sandbox Code Playgroud)

同样,<Modal>本地打开正常。无需动手动扳手模块本身,是否有更简单的解决方法或解决方案?

这是我的父组件:

import React, { Component } from "react";
import RecurringOutageComponent from "./components/RecurringOutageComponent";
import FutureOutageComponent from "./components/FutureOutageComponent";
import CurrentOutagesComponent from "./components/CurrentOutagesComponent";
import CreateModalComponent from "./components/CreateModalComponent";
import { Container, Row, …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails heroku hasownproperty reactjs react-bootstrap

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

如何找到并用“ None”或0替换Ruby哈希的“ nil”值?

我正在尝试在嵌套嵌套数组的迭代中向下钻取每个值,并用nil“ None”或0之类的值替换所有值。请查看我的代码显然不起作用。我需要先解决此问题,然后再将其传递给Rails视图进行迭代和渲染:

我的控制器:

def show
  results = Record.get_record(params[:trans_uuid])
  if !results.empty?
    record = results.map { |res| res.attributes.symbolize_keys }
    @record = Record.replace_nil(record) # this calls method in Model
  else
    flash[:error] = 'No record found'
  end
end
Run Code Online (Sandbox Code Playgroud)

我的模特:

def self.replace_nil(record)
  record.each do |r|
    r.values == nil ? "None" : r.values
  end
end
Run Code Online (Sandbox Code Playgroud)

record传递给Model方法时self.replace_nil(record如下所示:

[{:id=>1, :time_inserted=>Wed, 03 Apr 2019 15:41:06 UTC +00:00, :time_modified=>nil, :request_state=>"NY", :trans_uuid=>"fe27813c-561c-11e9-9284-0282b642e944", :sent_to_state=>-1, :completed=>-1, :record_found=>-1, :retry_flag=>-1, :chargeable=>-1, :note=>"", :bridge_resultcode=>"xxxx", :bridge_charges=>-1}]
Run Code Online (Sandbox Code Playgroud)

ruby hash null ruby-on-rails

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

React 组件中 Set 的迭代不会在 JSX 中呈现

我正在尝试迭代在 React 组件内的 props 中传递的 javascript Set() 。在迭代到位的情况下,我无法在屏幕上渲染任何内容:

 {selectedCity.forEach((key, value) => (
          return (
            <Row>
              <Col sm={12} md={6} mdOffset={4} lgOffset={4}>
                <Typography className="hide-mobile" h3>
                  TICKET PRICE FOR IN-STATE:
                </Typography>
                <Typography h3>{value.name}</Typography>
                <TicketPriceInput
                  onChange={e => {
                    setConcertDetails('price', e.target.value);
                    detectInputChange(e);
                  }}
                  value={price}
                  name="price"
                  isPriceChanged={isPriceChanged}
                />
                <OutPriceLabel className="hide-mobile">
                  <Typography h3>TICKET PRICE FOR OUT-OF-STATE:</Typography>
                  <Typography h3 bold className="hide-mobile">
                    {outLocationPrice()}
                  </Typography>
                </OutPriceLabel>

                <FootNote>
                  <Typography medium spaced className="hide-mobile">
                    *After the first 20 tickets anyone located in-state can
                    purchase tickets at the regular ticket price you set.
                  </Typography> …
Run Code Online (Sandbox Code Playgroud)

javascript iteration set jsx reactjs

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