我有一个无状态的反应组件,有点弹出。它从用户那里获取一些数据,并将其传递回其父级,并在父级中执行工作。
该组件拥有一个接受用户输入并将其发送回父级的handleSubmit() 函数的最佳方式是什么?
import React, { Component } from "react";
import "../../../node_modules/bulma/css/bulma.css";
const Transfer = (props, token, web3) => {
return (
<div className="modal is-active">
<div className="modal-background" onClick={props.onClick} />
<div className="modal-card">
<section className="modal-card-body">
<div className="content">
<h1 className="title"> Transfer Tokens </h1>
<p className="has-text-danger">
Requires that you are the owner of the token you are transferring
</p>
<p className="subtitle">How it works</p>
<p className="">
Enter the ID of the token you want to transfer, the address to
whom its going to, and thats …Run Code Online (Sandbox Code Playgroud) 构建要在生产中启动的应用程序 - 并不确定如何处理 AWS 上的开发/生产环境。
如果我使用多个存储桶、多个 DynamoDB 表、多个 Lambda 函数、多个 Elastic Search 实例、EC2、API 网关 - 拥有生产和开发环境似乎超级麻烦?
目前只有一个环境,一旦应用程序上线 - 任何更改都将改变生产环境。
那么如何处理 AWS 上的两个环境呢?我能想到的唯一方法是复制每个 lambda 函数、每个数据库、每个 EC2 实例、每个 API 和存储桶……但这实际上会花费双倍的价格,而且一旦上线更新起来会非常繁琐。
有什么建议么?
amazon-s3 amazon-ec2 amazon-web-services amazon-elastic-beanstalk aws-lambda
使用反应快照构建反应项目时出现错误。
我环顾四周,所有错误都与 puppeteer 有关 - 但我没有像这些问题一样使用 puppeteer 直接获取内容,因此答案不适用。
我认为问题在于,当react-snap渲染我的页面时,它们正在对我的服务器进行API调用,其中一些失败是因为它们未经身份验证或其他原因。但所有其他问题都表明这与“页面在完成之前退出”有关,我不知道当我运行react-snap 脚本时这意味着什么?它不像 puppeteer 那样获取页面。(也许是?我不知道,从未使用过 puppeteer)
这是我的脚本:
"start": "react-scripts start",
"build": "react-scripts --max_old_space_size=4096 build && npm run build-sw && npm run clean-cra-sw",
"clean-cra-sw": "rm -f build/precache-manifest.*.js && rm -f build/service-worker.js",
"test": "react-scripts test",
"eject": "react-scripts eject",
"build-sw": "node ./src/sw-build.js",
"postbuild": "react-snap"
Run Code Online (Sandbox Code Playgroud)
这是调试日志中的错误"npm run build"
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\Spader\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'build' ] …Run Code Online (Sandbox Code Playgroud) 我有一个在其他地方设置的特殊 URL,无法更改。
mydomain.com/discountCards
我需要从我的 s3 存储桶返回一个 JSON,每当服务器向 mydomain.com/discountCards
问题是:
我在 mydomain.com 上使用 React-Router 的 React 应用程序。因此,转到 mydomain.com/discountCards 会显示一个白色的反应页面(因为该网址上没有任何内容)
我正在尝试将 Cloudfront 设置为直接链接到有效的 s3 JSON 文件 - 但问题是:
它仅适用于 mydomain.com/discountCards.json 不适用于 mydomain.com/discountCards
所以....现在我的 s3 存储桶有一个名为 discountCards.json 的文件 - 但我需要它是没有“.json”的折扣卡。
或者是其他东西?
如何使用 AWS s3、cloudfront 和 route 53 从我的 s3 返回此 .json 作为特定域?
就像我说的那样,我通过指向我的 s3 文件的 cloudfront 进行了所有设置,但它要求我在 URL 中包含文件扩展名(我不能这样做,该 URL 已经在 mydomain.com/discountCards 上锁定,而不是 discountCards .json)
这样其他网站和应用程序就可以获取该 URL 并返回一个 json。任何其他方式来实现这一目标?
amazon-s3 amazon-web-services amazon-cloudfront reactjs react-router
reactjs ×3
amazon-s3 ×2
react-router ×2
amazon-ec2 ×1
aws-lambda ×1
javascript ×1
prerender ×1
puppeteer ×1
react-snap ×1