Closed leshalv closed 2 years ago
@1247748612
在Pro里 异步加载统一使用 options
ProFormTreeSelect 没有 options属性? @1247748612
fieldProps里
不太对吧
啊 你这不是异步请求吗 用request就行了
需要配合params来使用,才会生效对吧
不需要的
我这边试着看,只加载了一次,展开节点,并没有触发request
你得配置loadData去加载子节点 你看看文档
配合loadData加载子节点失败,报错Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method. at Tree
配合loadData加载子节点失败,报错Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
at Tree
那这可能是个bug 明天排查下
应该一起支持的,原来的loadData用起来很麻烦
应该一起支持的,原来的loadData用起来很麻烦
我没想到更好的办法支持
loadData会接收一个参数,但如果只用request实现的话,就需要把在loadData接收到的参数传递给request,现在能传递的只有一个keyWords。并且需要区分这是loadData触发的还是只是数据加载触发的。
不报错了,还是不行,走了onload,页面并没有展示数据 @1247748612 @chenshuai2144
不报错了,还是不行,走了onload,页面并没有展示数据
你仔细看看loadData的文档是怎么加载数据的
你如果一次获取所有的数据就直接使用request
loadData是提供给你附加数据的
好吧,异步加载到底怎么用呀,request也不行呀
好吧,异步加载到底怎么用呀,request也不行呀
不知道你是想怎么弄?如果是异步加载 可以直接在
request={async ()=>{ const respone=await fetch() return respone }}
我用这个 但是这个只有请求一次
const [state,setState] = useSafeState({
value: undefined,
treeData: [
{ id: 1, pId: 0, value: "1", title: "Expand to load",isLeaf: false },
{ id: 2, pId: 0, value: "2", title: "Expand to load",isLeaf: false },
{ id: 3, pId: 0, value: "3", title: "Tree Node", isLeaf: true },
],
});
const genTreeNode = (parentId, isLeaf = false) => {
const random = Math.random().toString(36).substring(2, 6);
return {
id: random,
pId: parentId,
value: random,
title: isLeaf ? "Tree Node" : "Expand to load",
isLeaf,
};
};
const onLoadData = ({ id }) => {
console.log(id);
return new Promise(resolve => {
setTimeout(() => {
setState({
treeData: state.treeData.concat([
genTreeNode(id, false),
genTreeNode(id, true),
genTreeNode(id, true),
]),
});
resolve();
}, 300);
})
};
<ProFormTreeSelect
name="participant"
label="指定参与人"
fieldProps={{
// showArrow: false,
// filterTreeNode: true,
// showSearch: true,
// dropdownMatchSelectWidth: false,
// labelInValue: true,
// autoClearSearchValue: true,
// multiple: true,
// treeNodeFilterProp: "title",
// // fieldNames: {
// // label: 'title',
// // },
options:state.treeData,
loadData:onLoadData,
}}
placeholder="选择参与人员"
/>
上面的 配置可以 跑下来 异步数据和多次请求~
ProFormTreeSelect 使用loadData时无效,发生错误 Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method. at Tree