Comments (6)
@albertwchang For simple and small project you can keep passing the ref to menuActions to your child components. I wouldn't recommend of doing this for mid or larger projects. You should use flux, reflux or any system that decouple these actions. if you need more help I can provide you a simple example.
p.s. I've been using refluxjs heavily in one big project contains 30 scenes and lots of animations. It's worth investing to those kind of frameworks.
from react-native-side-menu.
@alinz
how did you pass menuactions? the only way i see passing it right now is through menu, but there must be a way to also pass it to the child of sidemenu.
from react-native-side-menu.
Sorry for long delay, @Kevtastic, I've been busy with stuff. :D
So SideMenu component injects menuActions
object automatically to all its own direct children. Here's the code for that. So inside your child component you can access menuActions
by using this.props.menuActions
.
From that moment you can keep passing menuActions down to child's children components using the following code.
render () {
var props = this.props;
return (
<MyAwesomeChild menuActions={props.menuActions}/>
);
}
Or using es7 spread feature like this:
render () {
var props = this.props;
return (
<MyAwesomeChild {...props}/>
);
}
I might be wrong but based on my experience, I don't like to pass these actions down to hierarchy of children. I usually use flux
, reflux
architectures for doing these type of systems. But again it's your choice! :P Remember, we are still finding a lot of good patterns for writing apps using React.
from react-native-side-menu.
oh awesome! I actually moved the event I was worried about to flux in the mean time but this is super helpful regardless!
from react-native-side-menu.
Actually I have one more issue if you have the time. I'm actually trying to pass menuactions into the firstroute. More specifically, into the leftCorner button that I'm giving to firstroute. any ideas?
from react-native-side-menu.
@Kevtastic Not sure I got your second question about passing menuActions
into initial route, but if I got it correct, you need to use this.props.menuActions
in the first-level children. Like if you have
class SomeComponent extends Component
as a content-view /menu-view, and something inside it should use menuActions
, you can just access them via this.props.menuActions
but it works only for first-level children. I'll try to move it to context ASAP, mb @alinz would be also interested in that.
from react-native-side-menu.
Related Issues (20)
- OpenMenuOffset not working in production.
- Where did the Menu tags come from? HOT 2
- Hardware Back closes App on every scene in side menu
- Sample code does not work HOT 1
- Shadow/Elevation possibility feature request HOT 1
- undefined is not a function (near '..._react2.default.createClass...') Why am i getting this error ?
- TypeError Undefined is not a function (evaluating _firebase.default.initialize app) HOT 1
- SideMenu is visible below the component it is rendered on HOT 6
- 1 to 2 second delay when toggling menu HOT 3
- Crash on iOS when app built in release, works in debug HOT 3
- Is react-native-web supported? HOT 2
- All API props are not available in v1.1.3
- autoClosing prop does not work
- Use native driver for the animation HOT 4
- Side Menu stuck on android device, i can not click any where. it always appear at the left side of the screen and ovellaping the main screen content HOT 1
- Change style overlay
- componentWillMount has been renamed, and is not recommended for use HOT 1
- align problem when phone language is Arabic HOT 3
- Can we get a new release please? HOT 15
- Warnings HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-side-menu.