Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

actions[type] is not a function #2017

Closed
compojoom opened this issue Jul 12, 2017 · 12 comments
Closed

actions[type] is not a function #2017

compojoom opened this issue Jul 12, 2017 · 12 comments

Comments

@compojoom
Copy link
Contributor

I have this code with v3:

<Scene key="companies"
                           initial={loggedIn ? true : false}
                           hideNavBar={true} {...styles} type={ActionConst.BACK} component={Companies}/>

and I have a scene that calls Actions.companies({refresh: { goBack: true }})

that was working fine on v3, but on v4 I get actions[type] is not a function.

If I remove type={ActionConst.BACK}, then I no longer get the error, but the scene transitions from the wrong side. It seems like it's being added on the stack, but it should behave like pop() - removing the current scene to show the one below.

@quarryman
Copy link

try using type={'back'} instead.

@aksonov
Copy link
Owner

aksonov commented Jul 12, 2017

Not 'back', but 'pop'. I'm not sure about support of 'refresh' inside pop. Could you just raise two actions?

@compojoom
Copy link
Contributor Author

yep, it's pop and not back. But if I do use type={'pop'} navigating to this scene behaves like pop -> it just pops the last scene from the stack.

And since on the scene I am I have a tabbar -> when you navigate between the tabs and then hit the actions.companies() buttons you first switch between the tabs and once they are off the stack you navigate back to hte companies page. And I just want to directly transition back to companies no matter how many screens there are on the stack.

I tried popTo, but it seems to cause some endless loop or so... The app freezes :)

@aksonov
Copy link
Owner

aksonov commented Jul 12, 2017

You should pass child scene to pop to, not container one.

@compojoom
Copy link
Contributor Author

okaay, so adding type={'popTo'} to the scene seems to work fine.

Using Actions.popTo({scene: 'companies'}) seems to cause the endless loop

@aksonov
Copy link
Owner

aksonov commented Jul 12, 2017

Because 'companies' is not child.

@aksonov aksonov closed this as completed Jul 12, 2017
@compojoom
Copy link
Contributor Author

Why does companies need to be a child? It's a parent in this case and I would like to navigate back to the parent?

And what's with refresh now? Can we use it in v4 or not?

Actions.companies({
	refresh: {
	  goBack: true
	 }
 })

This doesn't seem to pass goBack as property to the previous scene. No matter if I use type={'popTo'} or not. It just doesn't seem to pass the property back to the previous scene. ComponentWillReceiveProps is never fired.

@aksonov
Copy link
Owner

aksonov commented Jul 13, 2017

'Companies' is stack. Stack cannot be presented, you always see some child within the stack.
'refresh' inside pop looks a little bit strange, have you tried just two calls - popTo & refresh?

@compojoom
Copy link
Contributor Author

Sorry, I'm lost. I don't understand what you mean with " Stack cannot be presented, you always see some child within the stack."

companies is the first scene in the stack.
I discovered that I can remove the type={'popTo'} from the scene definition. The way then to popTo this scene is by using
Actions.popTo('companies')
instead of v3 syntax
Actions.popTo({scene: 'companies'})

unfortunatly passing params as second argument doesn't do anything.

I tried it with 2 calls like this:

Actions.popTo('companies');
Actions.companies({wtf: true});

wtf was auto added to props.navigation.state.params. So we no longer need to use the refresh object?

@aksonov
Copy link
Owner

aksonov commented Jul 13, 2017

Have you tried Actions.popTo('companies');Actions.refresh({data}); ?

@compojoom
Copy link
Contributor Author

Yep,that also seems to work.
Are those 2 the same in behavior? Calling refresh on actions is somehow strange for me as I don't know on which scene the refresh is going to be called.

Actions.popTo('companies');
Actions.refresh({data}); 
Actions.popTo('companies');
Actions.companies({data});

@aksonov
Copy link
Owner

aksonov commented Jul 13, 2017

On current scene. After popTo currentScene is changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants