-
Notifications
You must be signed in to change notification settings - Fork 43
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
Inconsistencies in the volumes #1108
Comments
For this one the problem is in the initialization of the internal state of the component ( We can solve it by adding a For me, the solution is make that component stateless At the end, it is always dispatching the given diff --git a/web/src/components/storage/ProposalSettingsSection.jsx b/web/src/components/storage/ProposalSettingsSection.jsx
index 969d862b..871024d3 100644
--- a/web/src/components/storage/ProposalSettingsSection.jsx
+++ b/web/src/components/storage/ProposalSettingsSection.jsx
@@ -131,16 +131,14 @@ const SnapshotsField = ({
}) => {
const rootVolume = (settings.volumes || []).find((i) => i.mountPath === "/");
- const initialChecked = rootVolume !== undefined && hasFS(rootVolume, "Btrfs") && rootVolume.snapshots;
- const [isChecked, setIsChecked] = useState(initialChecked);
-
// no root volume is probably some error or still loading
if (rootVolume === undefined) {
return <Skeleton width="25%" />;
}
+ const isChecked = rootVolume !== undefined && hasFS(rootVolume, "Btrfs") && rootVolume.snapshots;
+
const switchState = (_, checked) => {
- setIsChecked(checked);
onChange({ active: checked, settings });
}; You may be wondering why this happens now and not before. The answer is in a change I did at 232096b, removing a not needed internal component in src/components/storage/ProposalPage.jsx. It was being redefined each time props changed. I.e., it was a different component every time, reason why all state pieces in the chain were removed and new ones were initialized instead of reusing the (no longer) existing ones. As you can see, this internal component introduced and hidden a not optimal behavior. So, we should be careful with them. |
Just in case the above is not clear enough, I've searched for an article explaining it better. I found this one: https://dev.to/shameel/the-terrible-react-anti-pattern-you-must-avoid-4el8. Hope it helps for a better understanding. |
This is caused because the following line was deleted by mistake from
|
Probably was removed by me when solving a conflict in that file 😢 |
This fixes #1108, both the problems and the implemented solutions are described there in depth. Tested manually to check both problems are indeed fixed.
Before merging #1104
After merging that pull request
a) It's not longer possible to add a
/home
volume although it's in the TW configurationb) The Btrfs switcher is not in sync with the table of volumes
The text was updated successfully, but these errors were encountered: