We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
根据代码
export const onRefresh = (screen, callback) => { if (!refreshMap.has(screen)) { refreshMap.set(screen, callback); } }
后续如果callback发生了改变,也不会重新更新 譬如
const usePatchData =(type)=>{ function onRefreshPatchData(){ console.log(type); } return [onRefreshPatchData]; } const [type,setType]=useState('A'); const [onRefreshPatchData] = usePatchData(type); onRefresh((toggled) => { onRefreshPatchData(); // 当type无论怎么变化 // log出来都会是'A' }; ```
The text was updated successfully, but these errors were encountered:
@HowardTangHw @itenl 这个问题有解决办法吗?我也碰到了这个问题,感觉是个大坑,useRefreshEndReached 里面所有的方法都有这个问题
Sorry, something went wrong.
@chachaxw 我的解决方法是这样的
const usePatchData =(type)=>{ const [count,setCount]=useState(0); useEffect(()=>{ // call api on this line console.log(type); },[count]) function onRefreshPatchData(){ setCount(pre=>pre+1); } return [onRefreshPatchData]; } const [type,setType]=useState('A'); const [onRefreshPatchData] = usePatchData(type); onRefresh((toggled) => { onRefreshPatchData(); }
需要加上一些checking,因为会比较频繁的调用到onRefreshPatchData
@HowardTangHw 我这边有个问题就是,调用 onReachEnd 方法的时候,回调函数执行有点奇怪,本来是加载更多数据,有时候能加载,有时候又加载不出来
No branches or pull requests
根据代码
后续如果callback发生了改变,也不会重新更新
譬如
The text was updated successfully, but these errors were encountered: