mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
1.5 KiB
1.5 KiB
The Plan for Modals
Where we are
- We're trying to move the entire codebase to hooks. With the possible exception of one component (ErrorBoundary) there should be no component in the codebase that must be a class.
- Right now, all modals are classes. One core reason for this is that
showModal
inapp/ui/components/modals/index.ts
directly callsshow
on the modal instance of a registered modal.
Where we're going
- Modal lifecycle state (hiding, showing, loading) will be managed with redux actions. This will eliminate the current blocker for moving to hooks.
- All modals will be hooks.
- Modals will thereby do their part in the larger mission of dropping the class-autobind-decorator dependency.
- Modals will use portals.
- Modals will not have to be singletons, making them more easily composable in the app's flows.
- Modals will not have to be loaded into the react tree at all times.
How we're going to get there
- refactoring all modals to use as little in the way of class-stuff as possible. For example:
- using
createRef
means that transition touseRef
will be much simpler since the semantics are the same between the two (but slightly different from the manual approach we often take). - reducing the number of class members as much as possible
- removing usages of class-autobind-decorator
- using
- As a middle step to getting to redux, we may opt to move to passing the
show
callback in toshowModal
as a callback (rather than calling it directly on an instance).