-
Notifications
You must be signed in to change notification settings - Fork 429
The way component should evolve #131
Description
Dear community,
I want to make a big refactoring of this component to reduce a crazy complexity we have now. This component has been started as a small proof-of-concept for RN side menu and nowadays it's a solid building block of many RN applications. I want to evolve this component, but I feel I can't do it without asking community about it. So, there are some topics I'd discuss with you:
Draggable behavior
My proposal is to separate side menu itself from draggable behavior.
const SideMenu = require('react-native-side-menu');
...
render() {
return <SideMenu/>;
}
// ^ SideMenu is draggable by default
I propose to use it like this
const SideMenu = require('react-native-side-menu');
const makeDraggable = require('react-native-side-menu/makeDraggable');
const DraggableSideMenu = makeDraggable(SideMenu); // or using ES2015 decorator
render() {
return <DraggableSideMenu>;
}
if you want to have a draggable menu. If you want a menu without draggable behavior, you can just use standard SideMenu
as in the example above.
Deprecate menuActions
Action object menuActions
is the other thing I'd like to discuss. I like how it works, but it also introduce some unnecessary complications in the code (component and user code as well). So what I propose is to make component as stateless as possible and control it from parent (unfortunately, I can't make this component 100% stateless, because it need to track current left offset for the content view). So, state of the component is going to be controlled from the parent:
render() {
return <SideMenu open={someIsOpenFlagHere} />
}
Every time you'll change this flag, open/close animation will work.
Deprecate disableGestures
This prop doesn't make any sense if we make draggable behavior pluggable.