小编Emr*_*ğan的帖子

有没有history.length的替代方案来升级react-router?

我想将react-router包升级到v6. 它对包有依赖性history,在history包路线图中,文档说history.length很快就会被弃用甚至删除。你可以看一下https://github.com/remix-run/history/issues/689

我想知道在将包升级到最新版本时是否有其他替代方案可以history.length在我的代码中使用。react-router

举个例子,我的用法之一:

  import { useHistory } from 'react-router';

  const history = useHistory();

  const onGoBack = () => {
    if (history.length > 2) {
      history.goBack();
    } else {
      history.push('/portfolio');
    }
  };
Run Code Online (Sandbox Code Playgroud)

reactjs react-router remix.run

9
推荐指数
0
解决办法
1296
查看次数

在C中使用"fscanf"如何拆分两个字符串?

我希望使用文件操作在C中的链表.我想得到一条线并将其拆分并存储在结构中.但我不能分裂两个字符串.

我的文件是这样的:

1#Emre #Dogan
2#John#Smith
3#Ashley #Thomas
等...

我想使用fscanf从文件中读取一行.

fscanf(file,"%d#%s#%s",&number,name,surmane);
Run Code Online (Sandbox Code Playgroud)

但结果是

编号:1
姓名:Emre #Dogan

如何摆脱名称中的#元素并将其拆分为姓名和姓氏;

c linked-list list scanf strtok

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

标签 统计

c ×1

linked-list ×1

list ×1

react-router ×1

reactjs ×1

remix.run ×1

scanf ×1

strtok ×1