Skip to content
This repository was archived by the owner on Sep 13, 2020. It is now read-only.
This repository was archived by the owner on Sep 13, 2020. It is now read-only.

The way component should evolve #131

@Kureev

Description

@Kureev

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions