[Stepper] Document how to avoid re-mounting between each step
See original GitHub issueIn my application, I was rendering two different material-tables in two different steps of the Stepper component. When trying to test switching between steps quickly it would begin slowing down considerably and eventually freeze (in which I had to close the browser tab to continue).
I’m not sure the process for contributing code so I’m attaching below how I went around this by instead setting display: none;
on all non-active steps.
interface StepContentProps {
component: any;
props?: any;
}
interface ContentProps {
stepContent: StepContentProps[];
activeStep: number;
}
const StepContent = ({ stepContent, activeStep }: ContentProps) => {
return (
<>
{stepContent.map(({ component: Component, props }, index) => {
return (
<Component key={index} style={{ display: activeStep === index ? 'inherit' : 'none' }} {...props} />
);
})}
</>
);
};
Here’s an example of what the array of StepContentProps looks like:
const stepContent: StepContentProps[] = [
{
component: MaterialTable,
props: {
title: 'Users',
columns: userColumns as Column<User | Inventory>[],
data: users,
options: { selection: true, filtering: true, tableLayout: 'auto' },
onSelectionChange: (rows) => {
setSelectedUsers(rows);
},
} as MaterialTableProps<User>,
}
]
Issue Analytics
- State:
- Created 3 years ago
- Comments:19 (9 by maintainers)
Top Results From Across the Web
Step, Stepper, Stepping Motor Basics - Anaheim Automation
WARNING – To avoid the possibility of electrical shock, perform all mounting and wiring of the stepper motor and driver system prior to...
Read more >All About Stepper Motors - Adafruit Industries
Obey the Law! Stepper motor phases are inductors, so they will resist rapid changes in current flow. But at the end of each...
Read more >How do you change the Stepper color on React Material UI?
Checkout what are the classes of step, stepIcon so you can ... You will see you can override colors on a per component...
Read more >Simple Example (Stepper Mount) - CamBam
The object is a mounting plate for a Nema 23 stepper motor and will include CAD, ... so the first step is to...
Read more >Choosing and connecting stepper motors - Not Maintained
The 4 wires map to the 4 output pins of each stepper driver on the Duet (see below for identifying ... Aside from...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Did you get any solution? I’ve been trying with vertical and horizontal stepper and
TransitionProps={{ unmountOnExit: false }}
but it doesn’t work, content is unmounted and mounted back, and selections/input data are no preserved.@kevinvugts Are you using the vertical stepper? I think that the behavior is correct. You will find #10569 for developers advocating for the current behavior. I’m reopening as, after all, we might benefit from documentation about it. The following should be enough:
What do you think about it? Do you want to open a pull request?