我有一个名为deleteSong
. 我想知道在突变通过后如何将多个查询传递到refetchQueries
?
this.props
.deleteSong({
variables: { id },
refetchQueries: [{ query: fetchSongs }] //<-- I only know how to pass 1 query
})
.then(() => {})
.catch(err => {
this.setState({ err });
});
Run Code Online (Sandbox Code Playgroud) 我将旋转器放在页面上,但什么也没看到。没有错误控制台或类似的东西。
这是我的代码:
import React, { Component } from 'react';
import { Spin } from 'antd';
import './App.css';
class App extends Component {
render() {
return (
<div className="App">
<Spin />
</div>
);
}
}
export default App;
Run Code Online (Sandbox Code Playgroud) 我目前有这个 JS 数组,我想将其转换为 YAML 文件。我尝试查找内容,我知道如何创建对象和数组,但不知道如何嵌套它们。
cartParams: [
{
title: Leg type,
options: [
Round,
Square
]
},
{
title: Leg width / diameter,
options: [
1.00 inches,
1.25 inches,
1.50 inches,
1.75 inches,
2.00 inches
]
}
]
Run Code Online (Sandbox Code Playgroud) 我正在使用 firebase 并注意到大多数方法都返回承诺,但在文档中这不是。是否可以将其变为承诺?
uploadTask.on(
'state_changed',
function(snapshot) {
const progress = snapshot.bytesTransferred / snapshot.totalBytes * 100;
console.log('Upload is ' + progress + '% done');
},
function(error) {
alert(error);
},
function() {
const downloadURL = uploadTask.snapshot.downloadURL;
console.log(downloadURL);
}
);
Run Code Online (Sandbox Code Playgroud) 我在文档中复制了这段代码:
window.recaptchaVerifier.render().then(function(widgetId) {
grecaptcha.reset(widgetId);
}
Run Code Online (Sandbox Code Playgroud)
然而在我的反应项目中grecaptcha
是未定义的。我不知道他们在哪里将其声明为变量或从 firebase 中的哪里获取它。
我正在使用Jest并尝试比较是否将我的身体格式化为对象的结构{cart_id: 'string', payment: 'string', site: 'string'}
,但是当我执行以下操作时:
test('paymentRequest should be formatted', () => {
expect(paymentRequest(paymentBody)).objectContaining({
cart_id: expect.any(String),
payment: expect.any(String),
site: expect.any(String)
})
})
Run Code Online (Sandbox Code Playgroud)
我收到上面的错误。我查看了文档,但不确定是否要像他们的示例中的示例一样进行toBeCalled处理:https ://facebook.github.io/jest/docs/en/expect.html#expectobject containsobject
这是图像:
<img src="src/img/image.svg" alt="" />
文件夹结构如下:
src
-img
-components
...etc
Run Code Online (Sandbox Code Playgroud)
但图像没有显示任何内容,并且我在控制台中收到 404 错误?
当我移动地图时,我有边界,但我不知道如何获取这些边界内包含的标记。我不想非得用new google.map...
。我想继续只使用React-Google-Map
. 如果这是不可能的,那么我将使用谷歌实例。
我将在下面发布我的代码。我正在控制台注销对谷歌地图的引用以及其中的道具onChange
。
Props => \n\nbounds:{nw: {\xe2\x80\xa6}, se: {\xe2\x80\xa6}, sw: {\xe2\x80\xa6}, ne: {\xe2\x80\xa6}}\ncenter:{lat: 53, lng: -7.77000000000001}\nmarginBounds:{nw: {\xe2\x80\xa6}, se: {\xe2\x80\xa6}, sw: {\xe2\x80\xa6}, ne: {\xe2\x80\xa6}}\nsize:{width: 1818, height: 455}\nzoom:10\n__proto__:Object\n\nMap Ref => GoogleMap\xc2\xa0{props: {\xe2\x80\xa6}, context: {\xe2\x80\xa6}, refs: {\xe2\x80\xa6}, updater: {\xe2\x80\xa6}, _getMinZoom: \xc6\x92,\xc2\xa0\xe2\x80\xa6}\n
Run Code Online (Sandbox Code Playgroud)\n\nimport React, { Component } from 'react';\nimport GoogleMap from 'google-map-react';\n\nfunction findMarkerIndex(id, markers) {\n for (let i = markers.length; i--; ) {\n if (markers[i].id === id) {\n return i;\n }\n }\n return …
Run Code Online (Sandbox Code Playgroud) 过去我就是Object.assign()
这样使用和完成的,但最近我被告知要使用扩展运算符。我想知道这是否是正确的做法,或者这是否会改变状态?
import constants from '../constants';
const initialState = {
all: null
};
export default (state = initialState, action) => {
switch (action.type) {
case 'ITEM_ADDED':
return { ...state, all: state.all.push(action.data) };
default:
return { ...state };
}
};
Run Code Online (Sandbox Code Playgroud) 我正在尝试做类似的事情:
firebase.auth().currentUser.updateProfile({displayName: 'test'})
.then(user => {
console.log(user);
})
.catch(err => {
console.log(err);
}
Run Code Online (Sandbox Code Playgroud)
但是控制台用户什么也没显示。它不会在承诺中返回任何内容吗?
我看过这篇文章:
带有 --dev 标志的 Yarn error "no such option"但它对我不起作用。我做了npm install --global yarn
,但没有用。
yarn version: 0.27
node version: 9.6.1
npm version: 5.6.0
linux-ubuntu: 17.10
Run Code Online (Sandbox Code Playgroud)
正在运行的命令:
yarn add --dev nodemon babel-cli babel-preset-env babel-preset-stage-3
Run Code Online (Sandbox Code Playgroud) 示例字符串: George's - super duper (Computer)
想要新的字符串: georges-super-duper-computer
目前的正则表达式: .replace(/\s+|'|()/g, '-')
它不起作用,并且当我删除空格并且-
之间已经有一个类似的东西george's---super
.
我想连接两个数组,但第二个数组首先出现.
例:
const arr1 = [1, 2, 3];
const arr2 = [4, 5, 6];
const combinedArr = arr1.concat(arr2);
console.log(combinedArr);
Run Code Online (Sandbox Code Playgroud)
我知道你可以简单地用arr2切换arr1并颠倒顺序arr2.concat(arr1)
,但有没有更好的方法或不同的方法呢?
javascript ×7
reactjs ×6
firebase ×3
antd ×1
apollo ×1
arrays ×1
gatsby ×1
google-maps ×1
graphql ×1
jestjs ×1
markdown ×1
promise ×1
react-apollo ×1
react-redux ×1
redux ×1
regex ×1
yaml ×1
yarnpkg ×1