Comments (3)
Got it working by moving the screen options to the wrapping component:
const LoginComponent = withNetworkConnectivity()(Login)
LoginComponent.navigatorStyle = { tabBarHidden: true, navBarHidden: true }
Navigation.registerComponent('Login', () => connect(mapStateToProps, mapDispatchToProps)(LoginComponent), store, Provider)
But I should still have a root component, because now i'm setting listeners on all screens. State will be updated on connection change, so it will try to set state on screens that are unmounted. Any idea how to accomplish this with react-native-navigation?
from react-native-offline.
Hi, thanks for submitting your issue.
I am actively working on a branch to release a new version of the library this week.
First of all, if you wanna integrate the library with redux
you need to pass false
to withNetworkConnectivity
, so it should be:
export const registerScreens = () => {
Navigation.registerComponent('Login', () => connect(mapStateToProps, mapDispatchToProps)(withNetworkConnectivity(false)(Login)), store, Provider)
Navigation.registerComponent('Home', () => connect(mapStateToProps, mapDispatchToProps)(withNetworkConnectivity(false)(Home)), store, Provider)
}
That way, the state is kept in the store and not passed down as a prop to your wrapped component.
In terms of statics hoisting, that will be fixed with the upcoming release, so you won't have to move the screen options to the wrapping component.
I haven't used react-native-navigation in any project so far, but based on the API it seems to me (at least for Android where I have some knowledge) every time you use Navigation.registerComponent
, the library is creating a new Android activity underneath the hood, so you will have different root components depending on your active screen.
That being said, you don't have to worry about listeners. There will be only one active at a time.
I don't know the implementation details on iOS but I guess they should follow a similar approach where the React context is scoped to the active screen.
Apart from statics hoisting, the new version will include Flow support and the possibility of cancelling enqueued actions with another redux action, like NAVIGATE_TO_ANOTHER_SCREEN
from navigation-alike libraries, where it may makes sense to discard the fetching action since it won't be relevant any longer, so stay tuned!
Also, if you have suggestions about new features for the library, feel free to open another issue with your ideas :)
from react-native-offline.
@rauliyohmc By wrapping up every screen, you end up doing HEAD requests on each navigation transition. Maybe the connectivity change logic could be managed by an event channel in redux-saga, so it could work without having a root component.
from react-native-offline.
Related Issues (20)
- Saga side effect not being called after an action is auto dispatched from the `actionQueue` (When network state changes from offline to online) HOT 4
- Many Retries HOT 2
- [Question] redux thunks is it necessary? HOT 2
- Still in active development ? HOT 4
- Upgrade Example App for current Expo Go version HOT 12
- Improve documentation HOT 2
- Problems with the connection in some devices HOT 5
- Actions from actionQueue are sometimes dispatched multiple times HOT 4
- TypeError: null is not an object (evaluating 'P.store') HOT 2
- [Question] Compatibility with RTK Query HOT 4
- Incompatible with react-redux v8 HOT 6
- Help Needed while re-starting/opening the app for POST type REST API with Redux Saga HOT 2
- useIsConnected not updating on Hermes enabled iOS non-debug build HOT 3
- www.google.com/sorry/index 405 HOT 2
- Intercept and queue actions after errors HOT 1
- useIsConnected returns null initially in 6+ HOT 4
- Warning: Possible Unhandled Promise Rejection (id: 0)
- Can I set pingServerUrl in networkSaga by a health check API?
- Getting TypeError in a Promise reject
- Reorder in queue
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-offline.