小编New*_*Aid的帖子

我怎样才能让Xcode在Mac Sierra上运行(10.12.6)

我似乎陷入了MacOS/Xcode炼狱.

我在OS Sierra/10.12.6上.

当我尝试更新时,我收到警告,升级与DisplayLink存在问题,因此无法完成.

这与Xcode直接冲突(现在,在App Store上)仅适用于10.13.2或更高版本.

我找不到下载早期版本的Xcode的地方.我无法升级到High Sierra.

我怎么能发生这种情况?

macos xcode macos-sierra

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

为什么Jest不会跑?"TypeError:environment.setup不是函数"

真的在这里争斗.

我的Circle CI测试失败了

FAIL  ./App.test.js
  ? Test suite failed to run

    SyntaxError: Unexpected token )
Run Code Online (Sandbox Code Playgroud)

我尝试在我的机器上本地运行Jest(一个CRNA)但我收到以下错误:

TypeError: environment.setup is not a function

所以这两个似乎都是节点版本/ ES6/babel问题,对吧?

我在(Path was expecting string等)之前遇到了一些错误,我通过安装jest-cli和更改节点版本等来解决这个问题.

我现在在: 节点 v8.9.1 npm 5.5.1

但现在我完全难过了.

所以:

TypeError: environment.setup is not a function 特定于jest-cli包.

我试过了:

i)在pkg json中将以下内容添加到jest配置中:

  "jest": {
    "preset": "jest-expo",
    "testMatch": [
      "*.test.js",
      "**/?(*.)(spec|test).js?(x)"
    ],
    "transformIgnorePatterns": [
      "node_modules/(?!(react-native|jest-cli)/)"
    ]
  }
Run Code Online (Sandbox Code Playgroud)

(认为​​这可能是'babel'模块,但是错误消息没有变化)

ii)更改babel-core版本,安装babel-node-modules,更改React Native版本,开玩笑等等.没有快乐.

救命?

在获取Create React Native App项目以在节点v5-v8上运行jest测试方面,我是否缺少一些东西?

正确难倒,它正在阻止我的Circle CI设置.

发送帮助或某种IPA啤酒来减轻我的沮丧.

javascript babel node.js jest react-native

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

Why can't Gatsby / Facebook find my og:image

I have a Gatsby app setup.

src/

---images/foo.jpg // <--- the img i want on my facebook shareable URL (og:image).

---images/ // <-- note, there are loads of PNG files i'm using that seem to trip/default onto the FB image/share.

---assets/ // <--- loads of SVGs i'm using that

---components/seo.js // component embedded at top of each page

---pages/index.js // page that uses <SEO />

Inside index.js:


function Home() {

    return (
        <React.Fragment>

            <SEO />

Run Code Online (Sandbox Code Playgroud)

Inside SEO:


const SEO …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs gatsby

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

我应该对功能组件使用_myMethod吗?

最近,我在博客上看到了很多例子,其中React功能组件中的方法都带有下划线。我还在基于类的组件中看到了这一点,并被告知这意味着它们是私有的(?)。

但是功能组件内部功能已经是私有的,无法在组件外部访问,对吗?

例:


function MyComponent({ propOne }) {

   const _getData() {
      /// Why does this have an _underscore on it?
   }
   return (
        <div>a div</div>
    )
}

Run Code Online (Sandbox Code Playgroud)

reactjs react-hooks

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

邮差工作,但fetch()没有.为什么不?

邮差请求似乎工作,但我不能让fetch()使用相同的请求和标头.它让我疯狂.

客户:

fetch('http://localhost:1234/acts/create', {
    method: 'POST',
    headers: {
        "Content-Type": "application/x-www-form-urlencoded",
    },
    body: JSON.stringify({
        name: 'BARNEY MCGREW!',
        rating: 90,
    })
})
Run Code Online (Sandbox Code Playgroud)

表达:

exports.act_create = function (req, res) {
    console.log(' req >>>>', req.body);
    var act = new Act(
        {
            name: req.body.name,
            rating: req.body.rating
        }
    );

    // res.set('Content-Type', 'application/x-www-form-urlencoded');

    act.save(function (err) {
        if (err) {
            return console.log(err);
        }
        res.send('Act Created successfully')
    })
};

Run Code Online (Sandbox Code Playgroud)

这会生成以下终端输出:

 req >>>> :  [Object: null prototype] { '{"name":"IngleburtHumperdink","rating":10}': '' }
act is:  { _id: 5c4245bea7bb511c20de6b7a }
Run Code Online (Sandbox Code Playgroud)

所以它有点过来,但后来我得到了ValidationError: Act …

javascript fetch express

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

为什么使用JS Promises而不是IF/ELSE/Ternary?

我正在阅读有关JS Promises的技能.

这里是我的奎德里:假设你想console.log('we done, bruh!') 您的数据的回来.

所以有了承诺,你可能会说:

let iWantToLogOut = function() {

    let data = fetch('https://jsonplaceholder.typicode.com/users')

    return new Promise((resolve) => {
        resolve(data)
    })
}
Run Code Online (Sandbox Code Playgroud)

然后解决这个承诺:

iWantToLogOut().then((dataBack) 
=> databack.json())
 .then((json) => {
   console.log('We done, bruh! Look: ', json)         
 })
Run Code Online (Sandbox Code Playgroud)

这太好了.您将获得API数据,然后我们将消息记录下来.

但这不是一件容易的事情:

   let data = fetch('https://jsonplaceholder.typicode.com/users');
   data ? console.log('we done, bruh!') : null;
Run Code Online (Sandbox Code Playgroud)

我可能过度简化/遗漏了一些东西(因为......好吧......我迟钝了)但我只是想确保在进入Async/Await之前我真正理解Promises.

javascript es6-promise

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