Reactjs 如何增强UI表单中挂钩视图的空状态

Reactjs 如何增强UI表单中挂钩视图的空状态,reactjs,react-hooks,state,react-hook-form,Reactjs,React Hooks,State,React Hook Form,当我试图在UI表单中增强钩子视图的空状态时,视图中没有要显示的钩子,但我试图在行为中看到除“无搜索项”之外的其他内容。我有点困惑,我可以添加什么逻辑来增强空状态 这是我的代码: export default class ListHooks extends Component { handleCreateHook = () => { this.props.history.push('/hooks/create'); }; handleHookSearchSubmit =

当我试图在UI表单中增强钩子视图的空状态时,视图中没有要显示的钩子,但我试图在行为中看到除“无搜索项”之外的其他内容。我有点困惑,我可以添加什么逻辑来增强空状态

这是我的代码:

export default class ListHooks extends Component {
  handleCreateHook = () => {
    this.props.history.push('/hooks/create');
  };

  handleHookSearchSubmit = hookSearch => {
    const query = parse(window.location.search.slice(1));

    this.props.history.push({
      search: stringify({
        ...query,
        search: hookSearch,
      }),
    });
  };

  render() {
    const {
      classes,
      description,
      data: { loading, error, hookGroups },
    } = this.props;
    const query = qs.parse(this.props.location.search.slice(1));
    const hookSearch = query.search;
    const tree = hookGroups
      ? hookGroups.map(group => ({
          value: group.hookGroupId,
          nodes: group.hooks.map(hook => ({
            value: hook.hookId,
            href: `/hooks/${group.hookGroupId}/${encodeURIComponent(
              hook.hookId
            )}`,
          })),
        }))
      : [];

    return (
      <Dashboard
        title="Hooks"
        helpView={<HelpView description={description} />}
        search={
          <Search
            placeholder="Hook contains"
            defaultValue={hookSearch}
            onSubmit={this.handleHookSearchSubmit}
          />
        }>
        {!hookGroups && loading && <Spinner loading />}
        <ErrorPanel fixed error={error} />
        {hookGroups && (
          <MuiTreeView
            // key is necessary to expand the list of hook when searching
            key={hookSearch}
            defaultExpanded={Boolean(hookSearch)}
            listItemProps={{ color: classes.listItemProps }}
            searchTerm={hookSearch || null}
            softSearch
            tree={tree}
            onEmptySearch={
              <Typography variant="subtitle1">
                No items for search term {hookSearch}
              </Typography>
            }
            Link={Link}
          />
        )}
        <Button
          spanProps={{ className: classes.actionButton }}
          tooltipProps={{ title: 'Create Hook' }}
          color="secondary"
          variant="round"
          onClick={this.handleCreateHook}>
          <PlusIcon />
        </Button>
      </Dashboard>
    );
  }
}
导出默认类ListHooks扩展组件{
handleCreateHook=()=>{
this.props.history.push('/hooks/create');
};
handleHookSearchSubmit=hookSearch=>{
constquery=parse(window.location.search.slice(1));
这个。道具。历史。推({
搜索:字符串化({
查询
搜索:钩子搜索,
}),
});
};
render(){
常数{
班级,
描述
数据:{正在加载,错误,hookGroups},
}=这是道具;
constquery=qs.parse(this.props.location.search.slice(1));
const hookSearch=query.search;
const tree=hookGroups
?hookGroups.map(组=>({
值:group.hookGroupId,
节点:group.hooks.map(hook=>({
值:hook.hookId,
href:`/hooks/${group.hookGroupId}/${encodeURIComponent(
钩子
)}`,
})),
}))
: [];
返回(
{!hookGroups&&loading&&}
{hookGroups&&(
)}
);
}
}