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
5.37.1
No response
所有手机上均不生效
https://codesandbox.io/p/sandbox/determined-resonance-jtpxhj?layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522cm0eoiiym00073j6nv6cxqxn2%2522%252C%2522sizes%2522%253A%255B100%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522cm0eoiiyl00033j6n5vkhogtn%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522cm0eoiiyl00043j6nasfmravh%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522cm0eoiiyl00063j6n4djq2r1d%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522cm0eoiiyl00033j6n5vkhogtn%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522cm0eoiiyl00023j6n1pj4bsvf%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fsrc%252FApp.tsx%2522%252C%2522state%2522%253A%2522IDLE%2522%252C%2522initialSelections%2522%253A%255B%257B%2522startLineNumber%2522%253A8%252C%2522startColumn%2522%253A27%252C%2522endLineNumber%2522%253A8%252C%2522endColumn%2522%253A27%257D%255D%257D%255D%252C%2522id%2522%253A%2522cm0eoiiyl00033j6n5vkhogtn%2522%252C%2522activeTabId%2522%253A%2522cm0eoiiyl00023j6n1pj4bsvf%2522%257D%252C%2522cm0eoiiyl00063j6n4djq2r1d%2522%253A%257B%2522id%2522%253A%2522cm0eoiiyl00063j6n4djq2r1d%2522%252C%2522activeTabId%2522%253A%2522cm0oyhbr5001b3j6m2o7p7hb9%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522cm0eoiiyl00053j6nznzfqkw5%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522UNASSIGNED_PORT%2522%252C%2522port%2522%253A0%252C%2522path%2522%253A%2522%252F%2522%257D%252C%257B%2522type%2522%253A%2522UNASSIGNED_PORT%2522%252C%2522port%2522%253A0%252C%2522id%2522%253A%2522cm0oyhbr5001b3j6m2o7p7hb9%2522%252C%2522mode%2522%253A%2522permanent%2522%257D%255D%257D%252C%2522cm0eoiiyl00043j6nasfmravh%2522%253A%257B%2522tabs%2522%253A%255B%255D%252C%2522id%2522%253A%2522cm0eoiiyl00043j6nasfmravh%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Afalse%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D
当与App传入的props 发生变化时,content就重新渲染,然后滚动到最下面的位置就跑到最顶上了。如何阻止content的重新渲染?
The text was updated successfully, but these errors were encountered:
有两处错误: 1.React.memo要和useMemo结合使用才有效果 2.Content组件的定义不应该放在Child组件中,否则每次Child渲染,得到的是一个全新的Content组件
child.tsx代码如下 `import React, { memo, useMemo } from "react"; import { Button, Popover } from "antd-mobile";
const Content = memo((prop) => { console.log("Content Render"); const { list } = prop; return ( <div style={{ height: "200px", width: "50px", overflow: "auto", }} > {list.map((item) => { return
const Child = (props) => { const { flag } = props;
const alphabet = useMemo(() => { return Array.from({ length: 26 }, (_, i) => String.fromCharCode(i + 65)); }, []);
return ( <div style={{ display: "flex", }} > <Popover content={} placement="bottom" mode="dark" trigger="click" destroyOnHide > 123
export default memo(Child); `
Sorry, something went wrong.
No branches or pull requests
Version of antd-mobile
5.37.1
Operating system and its version
No response
Browser and its version
所有手机上均不生效
Sandbox to reproduce
https://codesandbox.io/p/sandbox/determined-resonance-jtpxhj?layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522cm0eoiiym00073j6nv6cxqxn2%2522%252C%2522sizes%2522%253A%255B100%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522cm0eoiiyl00033j6n5vkhogtn%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522cm0eoiiyl00043j6nasfmravh%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522cm0eoiiyl00063j6n4djq2r1d%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522cm0eoiiyl00033j6n5vkhogtn%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522cm0eoiiyl00023j6n1pj4bsvf%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fsrc%252FApp.tsx%2522%252C%2522state%2522%253A%2522IDLE%2522%252C%2522initialSelections%2522%253A%255B%257B%2522startLineNumber%2522%253A8%252C%2522startColumn%2522%253A27%252C%2522endLineNumber%2522%253A8%252C%2522endColumn%2522%253A27%257D%255D%257D%255D%252C%2522id%2522%253A%2522cm0eoiiyl00033j6n5vkhogtn%2522%252C%2522activeTabId%2522%253A%2522cm0eoiiyl00023j6n1pj4bsvf%2522%257D%252C%2522cm0eoiiyl00063j6n4djq2r1d%2522%253A%257B%2522id%2522%253A%2522cm0eoiiyl00063j6n4djq2r1d%2522%252C%2522activeTabId%2522%253A%2522cm0oyhbr5001b3j6m2o7p7hb9%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522cm0eoiiyl00053j6nznzfqkw5%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522UNASSIGNED_PORT%2522%252C%2522port%2522%253A0%252C%2522path%2522%253A%2522%252F%2522%257D%252C%257B%2522type%2522%253A%2522UNASSIGNED_PORT%2522%252C%2522port%2522%253A0%252C%2522id%2522%253A%2522cm0oyhbr5001b3j6m2o7p7hb9%2522%252C%2522mode%2522%253A%2522permanent%2522%257D%255D%257D%252C%2522cm0eoiiyl00043j6nasfmravh%2522%253A%257B%2522tabs%2522%253A%255B%255D%252C%2522id%2522%253A%2522cm0eoiiyl00043j6nasfmravh%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Afalse%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D
What happened?
当与App传入的props 发生变化时,content就重新渲染,然后滚动到最下面的位置就跑到最顶上了。如何阻止content的重新渲染?
Relevant log output
No response
The text was updated successfully, but these errors were encountered: