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

General code clean-up

Compare
Choose a tag to compare
@Kureev Kureev released this 21 Dec 17:25
· 107 commits to master since this release

Hey folks!

It was a really busy time, but seems I've managed to find some for react-native-side-menu. In this release I've mostly concentrated on deprecating menuActions, context etc. I'm also planning a next step to move out a draggable behavior to standalone function. It'll make possible to use it like this:

const DraggableSideMenu = makeDraggable(SideMenu)

But that's a small spoiler for the upcoming x-mas major release. Let's now focus on the current one:

Deprecating menuActions

A while ago I've introduced a menuActions to manage side menu's state. Then we felt into some pitfalls with a way passing them down (thru props or context). Well, I didn't like using plain props, because you can't pass them to Nth child without having a lot of boilerplate in your code. So, at some point I decided to use a context for this purpose. Unexpectedly, some of people started to complain about using context (experimental feature + some "magic" in the code). Well, I'm agree, but it seems to be a lesser evil.

So, I though about it for a while and find out that we can actually remove a menuActions object (:open_mouth:). Instead, I propose to use a plain prop on SideMenu component (isOpen) and it's as simple as

<SideMenu menu={<Menu />} isOpen={true}>
  <Content />
</SideMenu>

How you'll provide isOpen flag to component - it's up to you. Personally I use redux library for my data flow, but for sure you can use something else.

Deprecating touchToClose

When I started to develop this component I had no clue how it should really behave. Eventually, @skevy submited a nice PR to add touchToClose feature. I think it's a too cool functionality to keep it under a flag. As far as I can't imagine any real valuable example of not using it, I decided to put it as a default behavior in this version 💃 .

Deprecating defaultOpen

Well, now we have an isOpen flag, so why should we keep this one? I think it did a trick pretty well, but now it's not even needed, so RIP, defaultOpen 💀

Conclusion