-
-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
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
Duplicated Sidebar Drawer components with the same content even using single Edge Sidebar #894
Comments
Thanks for putting this up. In v4, all 3 drawers (temporary, persistent & permanent) will be rendered. The purpose of this is to leverage css over js because it does not work well with server-side rendering in v3. consider this implementation using js (v3) const screen = useScreen() // will return 'xs' | 'sm' | 'md' | 'lg' | 'xl' | undefined
render() {
return (
<Drawer variant={variants[screen]} />
)
} The problem with this approach is there is no How to workaround in your caseI suggest that you lift your state and api call up and make your component pure (only ui renderer) function App() {
const [data, setData] = useState()
useEffect(() => {
callAPI().then(response => setData)
}, [])
return (
<Root>
<DrawerSidebar>
<YourComponent data={data} />
</DrawerSidebar>
<Root>
)
} |
Hi, thanks for quick response. In that case you right. There are also can be several ways to achieve this: 1 way) Adding-implementing some new flags (ex. serverSideRendering) to Root or scheme or builder or even leaf components like drawers.. With this way we can seperate logics for both serverside and client side renderings. 2 way) We continue rendering all drawers but except adding (reusing) children only to active drawer and rest will have an empty content. |
Hey everyone, I'm using version My problem is to run cypress, because it's duplicating the component tags. Actually I'm getting the sidebar 3 times: 2 inside Root component and 1 inside |
There are always 2 generated Sidebar Drawer components with the same content even using single Edge Sidebar. Seems the difference is only "display: none" property. You can reproduce it by chrome dev tools right clicking on any preset or example layout from https://mui-treasury.com/layout/presets/
React dev tools shows that all variants of Edge Sidebars (temporary, persistent, permanent) generates with the same content even using only one type. Actually I did not investigate the logic behind the sidebar creation process, but for me this is a bug. For example I want to fetch some data from remote server on sidebar content using React's hooks api when sidebar triggered or even the props of Root has been component changed. Then it will do the same operation more than 1 time. You can reproduce it just create simple component "Issue.tsx", add to sidebar content and try to change props.
This is same for componentDidMount if using class components.
Here is sample from https://mui-treasury.com/layout/presets/mui-treasury/
![Screen Shot 2020-07-12 at 00 25 58](https://user-images.githubusercontent.com/8967770/87233349-8bdb2000-c3d7-11ea-8d23-a0a8d253ca20.png)
The text was updated successfully, but these errors were encountered: