Closed fmmajd closed 7 years ago
I have exactly the same issue,
Actions.NAME
is not working, and when I console log Actions.NAME()
it prints undefined.
"react": "^15.2.1",
"react-native": "^0.31.0",
"react-native-router-flux": "^3.35.0",
so I found the solution, and apparently, we can Actions.go to scenes that are not the current scene's sibling. so in my case, I have to use Actions.tabsRoot. is there a workaround? is it gonna be added? I think lots of people would appreciate if it was added. tnx
@fmmajd I solved this issue by dispatching the Action.NAME
from the store rather than invoking it with Actions.NAME()
Try this:
dispatch(Actions.NAME)
I'm having the same issue.
@Zianwar - that didn't help in my case.
@fmmajd - can you show exactly what you did to get past this?
@Zianwar I actually don't want to complicate my app by adding reducer to routes.
@lynndylanhurley you can't use Actions.SCENE_KEY to go to a scene that is not current scene's sibling. the two scenes should have the same parent. so in my case, I can't use Actions.home, but I can use Actions.tabsRoot
I checked and there is no Actions.go
I'm trying to get to a nested scene inside a drawer
<Scene key="root" hideNavBar={true}>
<Scene key="drawer" component={Drawer} open={false}>
<Scene key="profile" component={Profile} title="Profile"/>
<Scene key="workspace" component={Workspace} initial={true}/>
</Scene>
<Scene key="login" component={Login} initial={true} type={ActionConst.REPLACE}/>
</Scene>
i'm trying to get from the login
to the Actions.workspace()
, which it doesn't work I have to use Actions.drawer()
(as @fmmajd mentions) and since workspace is the intial it works. However then from the drawer I want to go to Actions.profile()
and the only thing that works is Actions.profile({type: 'replace'})
which is not desired since I want to go back.
@fmmajd I did not understand how you solved it!
@juanpasolano in your case, I do not know. I just needed one scene and thus I made it initial.
but something I can think of for your problem, is that you add a scene in drawers, make it initial, and based on props decide which scene to go.
like:
<Scene key="decide" component={Decide} title="goSomewhere"/>
and then in Decide component constructor:
let target = this.props.destination;
if(target === 'profile')
Actions.profile({type:'replace');
else if(target === 'workspace')
Actions.workspace({type:'replace');
and finally, when in other components you wanna come to drawers scenes:
Actions.drawer({destination: 'profile');
Actions.drawer({destination: 'workspace');
this is not the perfect solution, it's just a workaround, but it should work.
any update for this issue?
hi I'm adding a simple login screen to my app, but I'm not able to call Actions.home once the user is authenticated. I have a button that when pressed, calls a function to connect to the server and get auth status, and when successful, I call Actions.home. but nothing happens. no error or warning. just nothing. I have tried all forms of it, Actions.home, Actions.home(), {Actions.home}, saving Actions.home as state in the constructor and then using state, ... nothing worked. but in my other screens when I call Actions.somewhere in onPress props it works. I read most of the issues here, and questions on StackOverflow(there weren't a lot), but couldn't understand what's wrong. I used all the solutions suggested everywhere, but nothing.
when I console.log(Actions.home), it's what I see:
when I console.log(Actions.home()), it says undefined.
Steps to reproduce
2.add router definition
3.add login screen and other functions
code for router.js:
code for login screen component used in router: