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

Refresh not working as expected in several cases #3240

Conversation

daviscabral
Copy link
Collaborator

Some small tweaks in the refresh method and a few new callbacks to allow some work around navigation events in order to get it updated.

Components are mounted at once - from what I could see - still checking it.

This PR will solve #3236, #3218, #3206, #3197, #3188.

Copy link
Owner

@aksonov aksonov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (for WIP)

…-not-working-as-expected

* master:
  Add more information to issue template to help figure out cause of problems (#3239)
@aksonov
Copy link
Owner

aksonov commented Sep 4, 2018

@daviscabral Is it ready to merge?

@aksonov
Copy link
Owner

aksonov commented Sep 4, 2018

I think no, could you tell me what issues/difficulties are?

@daviscabral
Copy link
Collaborator Author

Just lack of time - helping a friend with some stress test in his server right now - after finishing it I'll push the changes.

But what I am doing is to move the logic of onEnter from componentDidMount to the event listener willFocus. And the onExit to the didBlur. But I want to be sure that is really going to fix the issue - and also not break anything.

I am also extending the test suite - so it's possible to require that every new PR that fixes a bug comes in companion of a test that helps it to come back (and also in future upgrades).

@dextermb
Copy link
Contributor

dextermb commented Sep 4, 2018

😲cant wait to see everything functional again, @daviscabral @aksonov

@aksonov
Copy link
Owner

aksonov commented Sep 5, 2018

@daviscabral But how it will solve problems with passing params?

@daviscabral
Copy link
Collaborator Author

daviscabral commented Sep 6, 2018

@aksonov yes - that's going to fix that's as well. sorry - misunderstood the question. Some of the errors I saw in the issues opened were related with people relying in the regular life-cycle from the components, that now are not like before.

It's not actually directly attached - I am going to finish the changes and show to you here, not sure if this should exactly be merged, as it's probably not just extending/facilitating the use, but might be changing behavior.

@daviscabral
Copy link
Collaborator Author

@aksonov after this - could we get a new version? I tried the last time but due the lack of permissions I was not able to publish - so I reverted a few things. Ended doing a little mess here while you was not around.

@aksonov
Copy link
Owner

aksonov commented Sep 6, 2018

@daviscabral Sure, I'll publish new version once this PR is finished. Any ETA?

@daviscabral
Copy link
Collaborator Author

Should be there in a few hours - just finishing a few tests here.

…-not-working-as-expected

* master:
  fixes Actions.reset when getParent returns null (#3245)
  reset error prop for all actions
  improve ts typings
  README and ISSUE_TEMPLATE updated to reflect decision about 4.0.0-beta.x version (#3242)
  Add support for deprecated Tabs component (#3214)
@dextermb
Copy link
Contributor

dextermb commented Sep 6, 2018

@daviscabral you've managed to resolve the param issue?

@jaredkove
Copy link

Can't wait to get this update! Thanks @daviscabral

@daviscabral daviscabral changed the title [WIP] Refresh not working as expected in several cases Refresh not working as expected in several cases Sep 6, 2018
@daviscabral
Copy link
Collaborator Author

daviscabral commented Sep 6, 2018

Please, do not merge yet - I noticed a bug in the isStatelessComponent call - making it to pass a ref to the wrong kind of component.

I've updated the examples to some of the cases that people complained - but to hide or pass props - it's like @aksonov said before - wrap=false might be needed - or you will have to provide the right scene key to refresh or pop.

Below the tab bar toggle working:

Image from Gyazo

@daviscabral
Copy link
Collaborator Author

I would appreciate some help testing these changes by the people that were having the problems before we proceed. We might have to update docs too. Any voluntary?

@daviscabral daviscabral force-pushed the dc/issues/3236-3218-3206-3197-3188-refresh-not-working-as-expected branch from 9c2cd4d to d2eebbb Compare September 6, 2018 17:03
@dextermb
Copy link
Contributor

dextermb commented Sep 7, 2018

@daviscabral I will test it now and see if it works in my testcase

@dextermb
Copy link
Contributor

dextermb commented Sep 7, 2018

@daviscabral Attempted to see if it worked with the example I posted a while ago (challenge). But it didn't seem to get passed down 🤕

@dextermb
Copy link
Contributor

dextermb commented Sep 7, 2018

@daviscabral I've created a gist with the example I gave, along with the routes structure.

@daviscabral
Copy link
Collaborator Author

Can you try this? (just to test if I am correct about the key reference that we need to keep now. If thta's the case - like it happened with React Navigation - it will require some work from everyone to adapt to it.

onPress={() => Actions.pop(
        {
          ...props,
          refresh: { challenge: challenges[i] },
          key: 'root'
        }
      )}

I believe you are defining the params but they are not passed from top to bottom like before. Also, check this:

onPress={() => {
   Actions.ChallengesDetails();
   Actions.refresh(
        {
          ...props,
          refresh: { challenge: challenges[i] },
          key: 'root'
        }
      )}

@dextermb
Copy link
Contributor

dextermb commented Sep 7, 2018

@daviscabral Can do, but after installing this branch then swapping back to master my app doesn't load the initial scene anymore. Trying to debug that 😨

@dextermb
Copy link
Contributor

dextermb commented Sep 7, 2018

I've been trying to debug it myself from reading through code, but wouldn't the issues be happening with:

      if (!this[key]) {
        this[key] = new Function(
          'actions',
          'props',
          'type',
          `return function ${
            key.replace(/\W/g, '_') // eslint-disable-line no-new-func
          }(params){ actions.execute(type, '${key}', props, params)}`,
        )(this, { error: '', ...commonProps, ...props }, type);
      }

Source

@daviscabral
Copy link
Collaborator Author

I use this to help with the libs I help to maintain:

function rn-clean() {
  rm -rf android/build
  rm -rf ios/build
  watchman watch-del-all
  rm -rf $TMPDIR/react-*
  rm -rf $TMPDIR/haste-*
  rm -rf $TMPDIR/metro-*
  yarn start --reset-cache
}
$ cp [lib-path:react-native-router-flux(in this case)]/src/*.js [app-path]/node_modules/react-native-router-flux/src/
$ yarn install # in the project root 
$ rn-clean

For your case - probably worth also remove node_modules.

@daviscabral
Copy link
Collaborator Author

This is the piece that magically generates the methods with scene names. But it calls execute - with type jump for tabs - or push for everything else.

@dextermb
Copy link
Contributor

dextermb commented Sep 7, 2018

@daviscabral Alright, ive cloned down my app again. npm i then going to build and test with Expo

@dextermb
Copy link
Contributor

dextermb commented Sep 7, 2018

@daviscabral Isn't that magic function the point where it degregates props into the other functions then down to react-navigation?

@daviscabral
Copy link
Collaborator Author

You can place a console.log inside the execute - and you will see that the params get there. The problem seems to be that is not possible to put a lot of nested scenes like before without wrapping it with a navigator to manage this. This is what I am trying to confirm.

@dextermb
Copy link
Contributor

dextermb commented Sep 7, 2018

@daviscabral 😛 im trying to confirm it for you but my app doesn't want to play nice after changing versions

@dextermb
Copy link
Contributor

dextermb commented Sep 7, 2018

Was unable to get the app working again after trying different things, so i'm transplanting things into an application that uses React Navigation for now

@daviscabral
Copy link
Collaborator Author

I am getting this in - I can't reproduce that - but it fixed a few other cases and add more examples.

@daviscabral daviscabral merged commit 39ca508 into master Sep 11, 2018
@daviscabral daviscabral deleted the dc/issues/3236-3218-3206-3197-3188-refresh-not-working-as-expected branch September 11, 2018 07:43
daviscabral added a commit that referenced this pull request Sep 11, 2018
* master:
  Allow pop and refresh to receive `key` (#3240)
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

Successfully merging this pull request may close these issues.

4 participants