我正在从“节点调度”模块运行作业。
在本地主机上一切正常,但是当我在 Heroku 中上传到生产时却没有。
我在亚洲/耶路撒冷的设置 -> var config 中将时区更改为 TZ,但它仍然不起作用。知道为什么吗?上传我的代码,虽然我认为这是 Heroku 的东西,而不是代码。目前每分钟更新一次只是为了测试它,有用的是每 1.5 小时一次
const schedule = require("node-schedule");
const needle = require("needle");
let j = schedule.scheduleJob("* /1 * * * *", function() {
needle.put("https://myserver.herokuapp.com/myendpoint");
});
Run Code Online (Sandbox Code Playgroud) 是否可以使用 Microsoft Graph 查看所有组以及这些组内的所有用户?我在文档中没有看到类似的内容。
打电话时:
https://graph.microsoft.com/v1.0/groups/
Run Code Online (Sandbox Code Playgroud)
我获取了有关我的组的信息,但没有看到有关这些组中用户的任何信息。
我也尝试过打电话:
https://graph.microsoft.com/v1.0/{{userID}}/memberOf
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
{
"error": {
"code": "BadRequest",
"message": "Resource not found for the segment 'memberOf'.",
"innerError": {
"request-id": "13488c8e-124f-4161-ad2b-1dc03a302dc9",
"date": "2019-03-18T16:13:23"
}
}
}
Run Code Online (Sandbox Code Playgroud)
不确定为什么或者是否相关。
我向服务主体授予了所有 Microsoft Graph 权限。
我已经使用next.js在_app.js中启动了状态。我想在index.js文件中使用此状态。我该如何访问?
这是我的_app.js代码:
import React from "react";
import App, { Container } from "next/app";
import Layout from "../components/Layout";
export default class MyApp extends App {
constructor(props) {
super(props);
this.state = {
currencyType: {
name: "Ether",
price: 1
},
ethPriceUsd: 1
};
}
static async getInitialProps({ Component, router, ctx }) {
let pageProps = {};
let ethPriceUsd;
if (Component.getInitialProps) {
fetch(`https://api.coingecko.com/api/v3/coins/ethereum/
`)
.then(result => result.json())
.then(data => {
ethPriceUsd = parseFloat(data.market_data.current_price.usd).toFixed(
2
);
});
pageProps = await Component.getInitialProps(ctx);
}
return { pageProps, …Run Code Online (Sandbox Code Playgroud) 我在以下位置使用情感样式:
import styled from '@emotion/styled'
Run Code Online (Sandbox Code Playgroud)
我正在尝试将props传递给指南中提到的样式化组件:
https://emotion.sh/docs/styled
由于某种原因,它不起作用。我也使用TypeScript。我在这里将道具传递给名为StyleWrapper的样式化组件:
const ex: React.FunctionComponent<exProps> = props => {
return (
<StyleWrapper someNumber = {props.someNumber}
...
</StyleWrapper >
)
}
Run Code Online (Sandbox Code Playgroud)
在StyleWrapper中:
const ToolsHeaderColumn = styled.div`
padding-top: ${props => props.someNumber };
`
Run Code Online (Sandbox Code Playgroud)
我得到的是编译错误:
"Property 'someNumber ' does not exist on type
'Pick<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>,
HTMLDivElement>, "children" | "style" | "title" |
"color" | "hidden" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | ... 243 more ...
| "css"> & { ...; }'.ts(2339)
"
Run Code Online (Sandbox Code Playgroud) 我正在使用 react-apexcharts 库:https : //github.com/apexcharts/react-apexcharts。
当我导入一个将 lib 导入页面的组件时,当我导航到它时(客户端路由)效果很好。但是当直接使用 URL 访问页面时,我收到一个错误:
Cannot read property 'document' of undefined
TypeError: Cannot read property 'document' of undefined
at Object.<anonymous> (C:\Users\a\Desktop\b\b-client\node_modules\apexcharts\dist\apexcharts.min.js:1:433939)
at Object.<anonymous> (C:\Users\a\Desktop\b\b-client\node_modules\apexcharts\dist\apexcharts.min.js:1:433950)
at s (C:\Users\a\Desktop\b\b-client\node_modules\apexcharts\dist\apexcharts.min.js:1:395)
at Object.<anonymous> (C:\Users\a\Desktop\b\b-client\node_modules\apexcharts\dist\apexcharts.min.js:1:169139)
at s (C:\Users\a\Desktop\b\b-client\node_modules\apexcharts\dist\apexcharts.min.js:1:395)
at Object.<anonymous> (C:\Users\a\Desktop\b\b-client\node_modules\apexcharts\dist\apexcharts.min.js:1:456290)
at s (C:\Users\a\Desktop\b\b-client\node_modules\apexcharts\dist\apexcharts.min.js:1:395)
at C:\Users\a\Desktop\b\b-client\node_modules\apexcharts\dist\apexcharts.min.js:1:769
at C:\Users\a\Desktop\b\b-client\node_modules\apexcharts\dist\apexcharts.min.js:1:780
at C:\Users\a\Desktop\b\b-client\node_modules\apexcharts\dist\apexcharts.min.js:1:143
at Object.<anonymous> (C:\Users\a\Desktop\b\b-client\node_modules\apexcharts\dist\apexcharts.min.js:1:263)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
Run Code Online (Sandbox Code Playgroud)
值得注意的是,我使用的是使用服务器端渲染的 next.js。
代码与 IMO 无关,我只是从他们的 github 文档中创建了示例组件:
import Chart from …Run Code Online (Sandbox Code Playgroud) 我想在事件处理程序中使用突变。我的事件定义如下:
(JSX attribute) onOk?: ((e: React.MouseEvent<any, MouseEvent>) => void) | undefined
Run Code Online (Sandbox Code Playgroud)
这就是我从客户端调用突变的方式
export const IMPORT_INFO_MUTATION = gql`
mutation ImportPolicy($data: ImportPolicyInput!) {
importPolicy(data:$data)
{
_id
name
}
}
Run Code Online (Sandbox Code Playgroud)
最终我这样称呼它:
onOk={() => {
useImportPolicyMutation({
variables: {
data: {
jsonData: JSON.parse(importPolicyData)
}
},
})
}
Run Code Online (Sandbox Code Playgroud)
`不用担心突变中的变量和参数。他们很好。问题是我收到以下错误:
Unhandled Rejection (Invariant Violation): Invalid hook call. Hooks can only
be called inside of the body of a function component. This could happen for
one of the following reasons:
1. You might have mismatching versions of React …Run Code Online (Sandbox Code Playgroud) 我在类组件上使用了 this.refs,现在我将它重构为一个功能组件。我正在使用 ViewShot 库:https : //github.com/gre/react-native-view-shot 在之前的实现中,它的使用方式如下:
您的应用中有一个 QR 图像,并且您想在社交媒体上发送该图像,因此您将其包装在 ViewShot 中:
<ViewShot ref="viewShot">
<QRImage
address={....}
image={...}
/>
</ViewShot>
Run Code Online (Sandbox Code Playgroud)
然后,当您单击共享图像时,它会执行以下操作:
onQRImagePress = async (address: string) => {
const viewShotRef: any = this.refs.viewShot;
try {
const uri = await viewShotRef.capture();
const options: Options = {
url: "file://" + uri,
title: `address: ${address}`,
};
await Share.open(options);
}
catch (e) {
console.log(`Could not screenshot the QR or share it due to: ${e}`);
}
};
Run Code Online (Sandbox Code Playgroud)
所以我们使用类的 this.refs 来使用 ref。我想为一个功能组件做这件事。最好使用钩子。我知道 userRef 存在,但它对我不起作用。我也尝试过使用 createRef 但不确定如何正确实现它。
reactjs ×5
javascript ×2
next.js ×2
node.js ×2
react-hooks ×2
apexcharts ×1
css-in-js ×1
emotion ×1
express ×1
graphql ×1
heroku ×1
mutation ×1
react-native ×1
scheduler ×1
typescript ×1