小编beh*_*zad的帖子

为什么 create-react-app 将 App.js 组件更改为基于函数的组件?

正如我所注意到的,它似乎create-react-app改变了app.js基于函数组件的类组件,

知道他们为什么这样做吗?

reactjs create-react-app

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

iOS 通用链接打开应用,不触发应用委托方法

我正在尝试在 iOS 上启用通用链接(作为 Firebase 无密码注册的一部分)。在 iOS 13.2 上本地测试。

apple-app-site-association (AASA) JSON 如下所示 ( https://lokitools.page.link/apple-app-site-association ):

{"applinks":{"apps":[],"details":[{"appID":"43S54AHEMG.com.jkalash.Loki","paths":["NOT /_/*","/*"]}]}}
Run Code Online (Sandbox Code Playgroud)

通用链接确实打开了应用程序,但是我无法处理从它们打开的应用程序。委托方法:

  1. application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool
  2. application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool

从通用链接打开时不会被调用。尝试在后台运行的两个应用程序并强制关闭。AASA 验证器 ( https://branch.io/resources/aasa-validator/ ) 说文件看起来不错,我尝试通过重新安装应用程序并观察控制台日志来排除故障swcd( https://ios13.dev/universal-links -debugging-on-ios-13-cjwsux93w001p6ws1swtstmzc)但没有任何异常显示,看起来确实像下载了 AASA 文件。

我也尝试过遵循 Apple 的故障排除指南(https://developer.apple.com/library/archive/qa/qa1916/_index.html),但失败的最后一步(第 8 步)不包括我的情况,即应用程序确实打开了(iOS 检测到通用链接),但只是没有调用委托方法。

deep-linking ios swift ios-universal-links ios13

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

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned 的安全风险

要执行一些像installing typescriptvia这样的命令NPM,有时需要执行:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

在 PowerShell 中,当您想要更改此策略时,它会发出警告:

更改执行策略可能会让您面临安全风险

我的问题是,有人知道这样做有什么安全风险吗?像 typescript 这样的著名软件包是否有可能导致安全问题?

powershell npm typescript npm-scripts

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

当 0 为 falsey ReactJS 时如何设置此输入值

ReactJS 不喜欢 null 中的值<input>

警告:valueprop oninput不应为空。考虑使用空字符串来清除组件或undefined用于不受控制的组件。

伟大的。我的数据库经常返回 null,因为尚未设置任何内容。

我在 ReactJS 应用程序中动态呈现输入字段。

value={this.state[row_array[0]] || ''} 
Run Code Online (Sandbox Code Playgroud)

的值this.state[row_array[0]]有时为 0。我想将 0 放在文本字段中,但这计算结果为 false ......因此......空字符串''放在文本字段中。

问题是this.state[row_array[0]]可能是任何事情... 0 是大问题。

这有一些信息,但对我没有任何帮助https://github.com/facebook/react/issues/11417

关于如何设置它的任何想法value=0

javascript reactjs

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

FetchMore :请求每次执行两次

我正在尝试在评论部分实现分页。

我在网站上有正常的视觉行为。当我单击“获取更多”按钮时,会添加 10 条新评论。

我的问题是请求每次执行两次。我不知道为什么。第一次,它使用游标值执行,第二次没有它。似乎在每次 fetchMore 之后都会执行 useQuery 钩子。

任何帮助,将不胜感激。谢谢!

成分 :

export default ({ event }) => {
  const { data: moreCommentsData, fetchMore } = useQuery(getMoreCommentsQuery, {
    variables: {
      id: event.id,
    },
    fetchPolicy: "cache-and-network",
  });
  const getMoreComments = () => {
    const cursor =
      moreCommentsData.event.comments[
        moreCommentsData.event.comments.length - 1
      ];
    fetchMore({
      variables: {
        id: event.id,
        cursor: cursor.id,
      },
     updateQuery: (prev, { fetchMoreResult, ...rest }) => {
        return {
          ...fetchMoreResult,
          event: {
            ...fetchMoreResult.event,
            comments: [
              ...prev.event.comments,
              ...fetchMoreResult.event.comments,
            ],
            commentCount: fetchMoreResult.event.commentCount,
         }, …
Run Code Online (Sandbox Code Playgroud)

apollo reactjs graphql apollo-client

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

插入 std::map 时强制初始化为 0

我有一个std::map<std::string,std::size_t>键映射计数器。当我增加一个计数器时,我不知道它是否已经存在。如果是,则递增。如果不是,则设置为 1。这很容易做到:

std::map<std::string,std::size_t> counters;
//...
auto c_it = counters.find(key);
if(c_it == counters.end())
  counters.insert(key,1);
else
  (*c_it)++;
Run Code Online (Sandbox Code Playgroud)

这是一个简单的事情的很多代码......我想这样做:

counters[key]++;
Run Code Online (Sandbox Code Playgroud)

但这会产生未定义的行为,因为std::size_t()在映射中不存在计数器时调用,并且不能保证std::size_t()初始化为 0。

我看到了两个潜在的解决方案:

  1. 查找/创建类似于std::size_t使用默认构造函数创建时强制初始化为 0的类型。std或 中有这样的类型boost吗?
  2. 查找/创建一个专用分配器来替换std::allocator<std::pair<const Key,T>>作为std::map. 但我不知道该怎么做。

注意:我只使用 C++11(我不想要 C++>=14 的解决方案)

c++ stdmap size-t allocator c++11

0
推荐指数
2
解决办法
82
查看次数