Comments (16)
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.
@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.
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.
@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.
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.
@computerjazz I have almost the same code as you. What version of react-navigation are you using ?
from redux-helpers.
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 fromItemDetail
. Perhaps the component is no longer mounted at the time it would be called -- I think I've seendidBlur
called when using a TabNavigator.- I'm not seeing the actions called when navigating back via pull-from-edge gesture.
from redux-helpers.
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.
@Ashoat correct. I'm not sure if it's called when not using Redux, I haven't tested that.
from redux-helpers.
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.
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.
@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.
@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.
@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.
@computerjazz listener hasn't work still for me, I was also created the issue in your github project.
from redux-helpers.
[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)
- Issues in ThemeProvider HOT 3
- this .setState does'nt work in componnent didmount anyone can help me? HOT 3
- Is @react-navigation/core needed? v4.0.1 HOT 3
- Invariant Violation: App.router must be provided to createNavigationPropConstructor as of [email protected] HOT 2
- NavState missing routes
- React Nav 5 support - undefined is not object _core.NavigationActions.init HOT 7
- When will react-navigation-5 be adapted? HOT 2
- undefined is not object _core.NavigationActions.init HOT 2
- TypeError: undefined is not an object (evaluating 'Navigator.router')
- React navigation navigation.getChildNavigation is not a fucntion HOT 1
- createReactNavigationReduxMiddleware called more than once
- Cannot read property 'routes' of undefined HOT 2
- TypeScript typings rely on nonexistent @react-navigation/core libdefs HOT 4
- Typings error HOT 2
- Upgrading react-navigation from 1.0.0-beta.13 to latest, having trouble re-integrating my nested navigators with redux. HOT 3
- Cannot read property 'routes' of undefined - react-navigation 3.11, redux-helper 3.0.2 HOT 1
- createNavigationReducer on Web HOT 1
- Upgrading from 1.0.0-beta.21 to v4, gives navigation.getChildNavigation is not a function HOT 3
- Invariant Violation HOT 5
- Changing imports from @react-navigation/core to react-navigation breaks web apps HOT 3
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 redux-helpers.