Giter VIP home page Giter VIP logo

Comments (16)

warrenbell avatar warrenbell commented on May 2, 2024

After stepping through the code a little more, it looks like I can only listen to events of type "action". How do I listen to other events of type "willFocus", "willBlur", "didFocus" and "didBlur" ?

from redux-helpers.

Ashoat avatar Ashoat commented on May 2, 2024

@warrenbell, the eventName != 'action' condition is copied from react-navigation. I am not sure why the condition is there in the first place; I'd suggest posting an issue in the main react-navigation repo to find out.

The intention of this library is to provide the same functionality available with the out-of-the-box state management in react-navigation. I don't want to provide functionality react-navigation doesn't, as I imagine this functionality isn't meant to be supported in react-navigation.

from redux-helpers.

computerjazz avatar computerjazz commented on May 2, 2024

Are you passing the react-navigation middleware into createStore?
This was missing from the docs and tripped me up.

import {createStore, applyMiddleware} from 'redux';  
import reducer from './reducer';  
import { createReactNavigationReduxMiddleware } from react-navigation-redux-helpers

const middleware = createReactNavigationReduxMiddleware("root", state => state.nav);

const store = createStore(
    reducer,
    applyMiddleware(middleware)
  );

<Provider store={store}>
... etc

from redux-helpers.

warrenbell avatar warrenbell commented on May 2, 2024

@computerjazz Thanks, I had that covered. It just looks like the other event types are not handled yet in createReduxBoundAddListener of this package.

from redux-helpers.

computerjazz avatar computerjazz commented on May 2, 2024

But you're not getting the onFocus, onBlur, etc events? I have my nav hooked into redux and am receiving all events after making the above change.

from redux-helpers.

warrenbell avatar warrenbell commented on May 2, 2024

@computerjazz I have almost the same code as you. What version of react-navigation are you using ?

from redux-helpers.

computerjazz avatar computerjazz commented on May 2, 2024

react-navigation 1.5.11

Here's a sample project: https://github.com/computerjazz/ReactNavigationRedux
App.js
Navigator.js
ItemDetail.js

The only weirdness I'm seeing is that

  • didBlur is not called when navigating back from ItemDetail. Perhaps the component is no longer mounted at the time it would be called -- I think I've seen didBlur called when using a TabNavigator.
  • I'm not seeing the actions called when navigating back via pull-from-edge gesture.

from redux-helpers.

Ashoat avatar Ashoat commented on May 2, 2024

For the first one, you’re saying your event listener is not triggered for didBlur, right? Does it get triggered when not using Redux integration?

from redux-helpers.

computerjazz avatar computerjazz commented on May 2, 2024

@Ashoat correct. I'm not sure if it's called when not using Redux, I haven't tested that.

from redux-helpers.

Ashoat avatar Ashoat commented on May 2, 2024

Based on the code snippet I posted above, I think the answer is no. As far as I understand, this just isn’t a behavior that react-navigation supports.

from redux-helpers.

computerjazz avatar computerjazz commented on May 2, 2024

Makes sense. And I just confirmed that didBlur does get called when navigating forward. So I'm thinking the component unmounts before didBlur is called when navigating back.

from redux-helpers.

warrenbell avatar warrenbell commented on May 2, 2024

@computerjazz I am using an older version of react-navigation that does not have those events implemented yet. But I am still confused as to how it even works based on the code in this package createReduxBoundAddListener function that seems to just ignore every event type other than 'action'. Did you use createReduxBoundAddListener in your code ? How are you adding event listeners ?

from redux-helpers.

computerjazz avatar computerjazz commented on May 2, 2024

@warrenbell I haven't spent the time to understand what goes on under the hood, but I've included everything in the sample files above ^^

from redux-helpers.

warrenbell avatar warrenbell commented on May 2, 2024

@computerjazz Our code is the same. I will get react-navigation upgraded to a version that has these events and go from there. Thanks

from redux-helpers.

jsina avatar jsina commented on May 2, 2024

@computerjazz listener hasn't work still for me, I was also created the issue in your github project.

from redux-helpers.

Ashoat avatar Ashoat commented on May 2, 2024

[email protected] introduces a new export called createDidUpdateCallback that should fix this issue. Refer to the docs for how it's used.

from redux-helpers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.