-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Support of external navigation state (full redux support) #2115
Comments
Maybe you are using older version. Please check Example project from latest beta.14 - I definitely see FOCUS events:
```
2017-07-26 13:34:41.387 [info][tid:main][RCTBatchedBridge.m:77] Initializing <RCTBatchedBridge: 0x6180001b0f40> (parent: <RCTBridge: 0x6000000db040>, executor: RCTJSCExecutor)
2017-07-26 13:34:41.433 [warn][tid:com.facebook.react.JavaScript][RCTModuleData.mm:220] RCTBridge required dispatch_sync to load RCTDevSettings. This may lead to deadlocks
2017-07-26 13:34:41.653 [info][tid:main][RCTRootView.m:295] Running application Example ({
initialProps = {
};
rootTag = 1;
})
2017-07-26 13:34:41.657 [info][tid:com.facebook.react.JavaScript] Running application "Example" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
2017-07-26 13:34:41.741 [info][tid:com.facebook.react.JavaScript] Launch RENDER
2017-07-26 13:34:49.138 [info][tid:com.facebook.react.JavaScript] 'ACTION:', { type: 'Navigation/NAVIGATE',
routeName: 'login',
params:
{ tintColor: 'red',
cardStyle: { backgroundColor: 'white', shadowOpacity: 1, shadowRadius: 3 },
leftButtonTextStyle: { color: 'green' },
backButtonTextStyle: { color: 'red' },
initial: true,
hideNavBar: true,
init: true,
data: 'Custom data',
title: 'Custom title',
routeName: 'login' } }
2017-07-26 13:34:49.139 [info][tid:com.facebook.react.JavaScript] 'ACTION:', { type: 'REACT_NATIVE_ROUTER_FLUX_BLUR', routeName: '' }
2017-07-26 13:34:49.141 [info][tid:com.facebook.react.JavaScript] 'ACTION:', { type: 'REACT_NATIVE_ROUTER_FLUX_FOCUS',
routeName: 'loginModal',
params:
{ tintColor: 'red',
cardStyle: { backgroundColor: 'white', shadowOpacity: 1, shadowRadius: 3 },
leftButtonTextStyle: { color: 'green' },
backButtonTextStyle: { color: 'red' },
initial: true,
hideNavBar: true,
init: true,
data: 'Custom data',
title: 'Login',
routeName: 'login',
leftTitle: 'Cancel',
onLeft: [Function] } }
2017-07-26 13:34:49.156 [info][tid:com.facebook.react.JavaScript] Login RENDER
2017-07-26 13:34:49.173 [info][tid:com.facebook.react.JavaScript] 'ACTION:', { type: 'Navigation/SET_PARAMS',
key: 'Init-id-1501068881684-14',
params:
{ title: 'Login!',
rightTitle: 'rightTitle',
onRight: [Function: onRight] } }
2017-07-26 13:34:49.174 [info][tid:com.facebook.react.JavaScript] 'ACTION:', { type: 'REACT_NATIVE_ROUTER_FLUX_BLUR', routeName: 'launch' }
2017-07-26 13:34:49.175 [info][tid:com.facebook.react.JavaScript] 'ACTION:', { type: 'REACT_NATIVE_ROUTER_FLUX_FOCUS',
routeName: 'loginModal',
params:
{ tintColor: 'red',
cardStyle: { backgroundColor: 'white', shadowOpacity: 1, shadowRadius: 3 },
leftButtonTextStyle: { color: [Getter/Setter] },
backButtonTextStyle: { color: 'red' },
initial: true,
hideNavBar: true,
init: true,
data: 'Custom data',
title: 'Login!',
routeName: 'login',
leftTitle: 'Cancel',
onLeft: [Function],
rightTitle: 'rightTitle',
onRight: [Function: onRight] } }
2017-07-26 13:34:49.726 [info][tid:com.facebook.react.JavaScript] Login RENDER
```
|
I am certainly not using an older version - I'm currently running
... or by just putting my own reducer directly into a function and returning it to the createReducer prop.
But I don't know where to go from here, since I'm using Redux and it's not apparent to me how I utilize the data when I don't have access to them from my Redux reducers. At this point I'm not using the |
@rasmniel Could you post link to sample repo with redux usage? I'm using MobX but will try to help if you provide the example. Probably I have to modify RNRF to work with external state provider. |
I am also having issues and am currently not able to persist the router state because of this. Its not showing up in redux at all. It doesn't seem like the connect function connects the state of the router with the store. |
@aksonov I have constructed a little You will find that the router behaves exactly as described above. Thanks for your effort! |
@hellsan631 RNRF v4 manages navigation state by itself, like v3 version did. I will think how to work with external state, it could be good enhancement. |
@rasmniel Thanks, will take a look |
@aksonov how do you persist the router state when your application closes? My Idea for a work-around was to keep track of a state change on the router and during rehydration (loading of an existing state) I could navigate the router to the desired component, but it throws errors about setting state during a router transition. |
@hellsan631 It will work after this enhancement will be done. |
@rasmniel Your example is very helpful. One difficult thing to implement is creation of initial state - reducer must know it at compile time, but Router is created later, runtime. Any ideas how to avoid it? |
I am afraid I don't have the answer, but in regards to initializing state, I found this Redux library, which might contain some code that could serve as an inspiration: redux-async-initial-state I'm guessing you will be able to create an initial state for the Router, which is then be injected into the Redux store as an enhancer, through the |
Probably I will restore old v3 syntax |
I don't mind that syntax - so if it enables storing navigation state inside Redux without breaking new functionality, I say do it! |
@rasmniel Okey, please check https://github.com/aksonov/rnrfSample |
Check latest master now. |
There you go! This works as expected, and events are now firing properly within Redux. |
I tried the sample project and it works fine, really need RNRF + Redux. Still not actually use it in my production, but by changing RNRF version from Actually I was trying to show header above |
I think with https://github.com/aksonov/react-native-router-flux/issues/2151 I should stick with |
I can make it works with |
@jordenchang55, did you happen to figure out a fix for the warning about not updating during a render? |
@zlandau2, Sorry for my poor English. What do you mean figure for a fix? |
Update rnrf too
… 27 нояб. 2017 г., в 11:07, RadiksMan ***@***.***> написал(а):
when i update test project (https://github.com/aksonov/rnrfSample) to "react": "16.0.0-beta.5",
"react-native": "0.49.5",
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Update all, but the error still remains ( |
@RadiksMan have you solved it? |
@kajm No |
@aksonov I did the smallest possible example from your example (https://github.com/aksonov/rnrfSample) and i got this error. What do you think cause this error? |
@kajm same here |
I'm having a different issue, I followed the example almost exactly and getting this error: My libraries are:
containers/main.js
reducers/router.js
reducers/index.js
|
@digitaldavenyc |
@kajm same here. |
@gsulloa i actually ended up with react-native-navigation by wix instead. Works good in my opinion. |
will |
No, it is not related to this topic. Check forked redux sample https://github.com/aksonov/rnrfSample |
@code-freakz import sentence will be auto moved to the top of file, use require instead. |
@aksonov yes I have downloaded that sample and ran it ok, but it has to be configuared depending on the special branch instead of latest mater, so I ask if(when) that branch will be merged back. |
No, it should work with latest master, please check |
|
@fatfatson I get the same error |
Need to adopt latest version then... It worked before |
@code-freakz I tried that and I still get the undefined property error on |
@aksonov Are you sure the code sample will work with the latest on master? |
@aksonov Your sample works until 4.0.0-beta.23. On version 4.0.0-beta.24 and later it gives the error shown on fatfatson comment. |
Yes, then deep linking is the reason... I don't know how deep linking should work for external state yet. PR is welcome. |
@digitaldavenyc did you find anything ? iam getting the same error . please help me |
@prudhvir3ddy I am sorry but I have had to deprecate our integration with RNRF and Redux. It's creating a fairly serious problem for us and may have to just engineer an undesirable solution. |
@digitaldavenyc 3.43.0 is working good with latest RN you can try that |
@prudhvir3ddy We have spent a lot of time converting to RN 4.0 Beta, downgrading isn't really an option for us at this point. |
if any one knew which version working correctly? i tried beta 23,25,27 and 31 sadly nothing seems working, Please help |
Hi, I am using following configuration for my project : react : 16.6.3 So I am trying to integrate redux with my scenes. My Scene Component
My App.js Class ( Starting Class )
My Routes Class :
So my otpSend dispatch method is triggered as expected. What doesn't work : My The componentDidUpdate method is not triggered. I am not sure what I am missing or if it is not supported at all by RNRF. Could someone please help me out here 🙏 Update : I got it to work.. Just upgraded libraries and it started to work :| |
Solved: Integrating the router with Redux is now possible. Check out this repo for an example: https://github.com/rasmniel/rnrfSample
I'm using the
react-native-router-flux
library and I want to store the current scene on state.The problem is that the events in the reducer don't fire when navigating.
The app starts up like this:
My reducer looks like this (in
routeReducer.js
):... and is combined like this (in
reducers.js
):No errors are raised and everything else works as expected - the router works fine for navigation and basic functionality, but none of the events are fired as expected.
I can't seem to find a solution to this problem anywhere. Am I missing a step? I followed the documentation in the library repo (I used
docs/v3
as there seem to be no v4 docs yet), but I don't know if I misunderstood something or this is caused by some of the recent updates being pushed to the library (I'm currently on version4.0.0-beta.14
). Any help is appreciated - Thanks!The text was updated successfully, but these errors were encountered: