-
Notifications
You must be signed in to change notification settings - Fork 172
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
Removal of isOpen
?
#121
Comments
I like this idea a lot. A wrapper component is must have. It makes the library more readable and nicely separates controlled (stateless component) and uncontrolled (wrapper component) approaches. The problem is, this means to do a complete rewrite. |
I think you might be able to do this by just taking all of the state and moving it to an HOC, and export both. That way it's an upgrade, not a rewrite. I'd be willing to start a PR if that's something you're interested in. |
@evandavis Yes, please! That's exactly what I want to do. Ideally, it should still pass all (or most of) current tests. |
See https://github.com/STRML/react-portal-minimal - I have not yet built the compatibility layer, but as you can see the project is much simpler without the state. |
Removed: #157 |
Related to this comment, I always thought it odd that this component had a property
isOpen
for conditional rendering, when developers are capable of managing that themselves:Ideally, the user should manage the state themselves and Portal should have no state.
Existing helpers like
closeOnEsc
should then only call theonClose
callback, and not actually close the portal unless the developer desires.This also solves a few bugs, like the following:
isOpen={true}
andcloseOnEsc={true}
componentWillReceiveProps
to be calledTo ease the transition, perhaps it would make sense to ship a wrapper component that manages this state for you for common cases. This is similar to what I have done in other projects with
<Resizable>
/<ResizableBox>
and<Draggable>
/<DraggableCore>
, which has worked nicely.Said stateless component would also serve as a very low-overhead building block for other components.
The text was updated successfully, but these errors were encountered: