Issue with the collapse animation in ReactJS Material UI after implementing a new component

Hello fellow developers! Check out this code example for a smooth collapse using Material UI: Code Example

I noticed that when I move JSX to an external component, the smooth effect breaks. I've provided examples with and without smooth collapse for comparison.

Any tips on how to keep Lists in an external component while maintaining smooth collapse functionality?

Answer №1

When JSX is placed into an external component

Your approach lacks the use of a true external component, as you have defined Lists within NestedList, causing it to be recreated with every render.

To achieve the desired outcome, consider creating a separate Lists component that receives necessary props from its parent:

<Lists open={open} handleClick={handleClick} />

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ways to obtain GitHub username using Firebase GitHub Authentication

I need assistance with retrieving the username of the user during authentication using Firebase Github Auth. I am able to access all user information except for the username. Below is the code snippet: import React, { useState, useContext, createContext, u ...

Troubleshooting: React Native Web Throws an Error When Using React Native Paper Provider and React Navigation NavigationContainer

As a newcomer to React-native and React-native-web, I find myself facing a challenge while working on an existing project. This project utilizes the React-Native-paper library and the @react-navigation/native library. Currently, I am attempting to adapt th ...

Tips for accessing subdocument data from Mongoose in the frontend using ReactJs

I am looking to retrieve comprehensive information about a collection known as "commercant", which includes another collection called "personne" in the front end using ReactJs. Although Postman returns all data, the front end is struggling to interpret the ...

Encountering an issue while trying to deploy my Next JS project on my local machine

I downloaded a fresh NextJS project from GitHub with just the basic setup and then ran the following commands: npm i npm run dev Whenever I try to access localhost:3000, I encounter this issue repeatedly: https://i.stack.imgur.com/QG9pd.png It appears to ...

Having trouble integrating MaterialUI Datepicker, Dayjs, useFormik, and Yup

Currently, I am facing a recurring issue with the Material UI Date picker in conjunction with day js. The problem arises when I select a date on the calendar for the first time, it updates correctly in the text field but fails to work thereafter. Additiona ...

Navigating to different pages while passing state or props can be achieved by using the router.push method in Next.js

Previously, I was utilizing the router from 'next/router', but after checking out the documentation for version 13, it seems that I need to switch to using 'next/navigation'. However, I am unsure how to pass user data to navigate with t ...

Error during Next.js compilation, undefined property

On the index page, there are components that display ads. const App = ({ads}) => ( { (ads.items===undefined) ? <></> : ads.items.map(item => <Ad item={item} key={item.postingId} id={item.postingId}/>) } ) export async function g ...

Tips for sending values via props to a different component and the common error message: "Consider using the defaultValue or value props instead of setting selected on the <option> element"

Currently, I am attempting to pass the selected value using the prop: handle state change, but encountering two errors. Error 1 : Instead of setting selected on <option>, use the defaultValue or value props. Error 2 : A property 'active' ...

What is the method to render certain text as bold using a json string?

I need assistance with concatenating two strings in react while ensuring that the first string is displayed in bold, while the second one remains unchanged. The first string I want to emphasize is stored in a JSON file, and the second string comes from an ...

Having trouble utilizing the DatePicker component in my react native application

I've encountered an issue while using DatePicker in react native. Whenever I try to use it, an error pops up saying: "render error a date or time must be specified as value prop". Here is the link to my repository: my github repository const [date, se ...

The material UI tabs text is missing the ellipses due to a coding error

As a newcomer to web development, I am experimenting with adding an ellipsis to the span element within the tabs. <div class="MuiTabs-scroller MuiTabs-fixed" role="tablist" style="overflow: hidden;"> <div class="MuiTabs-flexContainer"> ...

Warning in Next.js 13 (with App Directory): The prop `className` does not match

I have embraced the latest version of Nextjs 13 along with an app directory structure. In my setup, I am utilizing the "styled-components" library in conjunction with "Material UI." Despite following the recommended precautions to prevent errors, I find m ...

Encountering a problem with the navigation bar in the latest version of Next.js, version 13

"use client" import {Navbar, Button, Link, Text} from "@nextui-org/react"; import {styled} from "@nextui-org/react" const Box = styled("div", { boxSizing: "border-box", }); const AcmeLogo = () => ( ...

Material UI transitions between states when an individual item from the ItemList is clicked

Currently facing an issue with selected props from material UI. My goal is to have only one item selected at a time when clicked, but right now both items get selected simultaneously when any one of them is clicked. I hope that explanation is clear. impo ...

Automating the box selection process using table-react functionality

I am facing an issue with table-react. I need to implement a functionality where certain checkboxes should be checked based on user permissions. For instance, if the user has an id = 3 and can view companies with ids: 5, 6, 7, the checkboxes corresponding ...

Tips for incorporating dynamic content into React Material UI expansion panels while maintaining the ability to have only one tab active at a time

I'm working on a project using WebGL and React where I generate a list of users from mock data upon clicking. To display this content in an accordion format, I decided to use Material UI's expansion panel due to my positive past experience with ...

Is it still possible to utilize ref in React Native despite its deprecation?

I need help with updating my code that uses the ref attribute to show a custom alert. I received a warning about deprecation, so I'm looking for a replacement method or alternative solution. Can you provide some guidance on how to achieve this? <My ...

While utilizing Next.js Image, I encountered the issue of receiving a `403` error when attempting to load the image from the specified URL: `https://amandascookin.com/wp-content/uploads/2012/02/Crispy-Potatoes

When using the Next.js Image component with the URL https://amandascookin.com/wp-content/uploads/2012/02/Crispy-Potatoes-680.jpg, I am receiving a 403 error. Interestingly, when testing the same in a nextjs code sandbox, it works perfectly fine. I'm u ...

Locating the DataGrid Component in Material-UI v5: A Guide on Installing DataGrid in React

After updating material-ui/core to version 5.0.0-beta.1 and material-ui/lab to version 5.0.0-alpha.30, I am unable to find the DataGrid component. It does not seem to be included in either material-ui/core or material-ui/lab. Additionally, the documentat ...

In TypeScript, the error "Property does not exist on type 'any[]'" indicates that a specific property is not recognized on

Working on my project using Textscript in Next Js has been mostly smooth sailing, but I keep encountering warnings in my script that say 'Property does not exist on type any[ ]'. The red line under the name, image, and price properties is a sourc ...