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

Selectors do not hot reload #83

Closed
slorber opened this issue Feb 17, 2016 · 9 comments
Closed

Selectors do not hot reload #83

slorber opened this issue Feb 17, 2016 · 9 comments

Comments

@slorber
Copy link

slorber commented Feb 17, 2016

With webpack hot reloading, when fixing a bug inside a selector, the React view does not reflect the change after hot reloading.

Any reason for this?

Maybe the memoized values should be trashed on reload?
Or maybe it's react-redux connect that should reconnect on selectors updates?

@gaearon
Copy link

gaearon commented Feb 17, 2016

My guess is they will hot reload it you use React Hot Loader but not React Transform because gaearon/babel-plugin-react-transform#26. This is not specific to selectors at all: the bigger issue is we don’t update the wrapper components currently.

@slorber
Copy link
Author

slorber commented Feb 17, 2016

@gaearon thanks for the link will check it.

But I'm currently using React Hot Loader and not a babel transform :)

@gaearon
Copy link

gaearon commented Feb 17, 2016

Can you set up a small project reproducing the issue?

@slorber
Copy link
Author

slorber commented Feb 17, 2016

Hmmm thinking about it, this probably happens because I don't use Reselect with Redux so I guess it may work better if replaceReducer of redux is triggered and the selectors are in the same file as the reducers?

I'll have to investigate a bit more but I don't have time right now.

This is probably not really helpful but my selector that could not hot reload was:

exports.sortedFolderTagsSelector = createSelector(
  [
    exports.folderTagsSelector,
    AppCommonStore.selectedTagsSelector
  ],
  (folderTags,selectedTags) => {
    if ( folderTags ) {
      const sortedTags = _.orderBy(
        folderTags.tags,
        [tag => _.includes(selectedTags,tag.value),"count","value"],
        ["desc","desc","asc"]
      );
      return {
        ...folderTags,
        tags: sortedTags
      }
    }
  }
);

@gaearon
Copy link

gaearon commented Feb 17, 2016

It has more to do with where updates bubble then what selector is like. If you import selectors from components, React Hot Loader should pick up the updates. If it doesn’t, please post a project reproing this so I can look.

@ellbee
Copy link
Collaborator

ellbee commented Feb 24, 2016

@Slober I'm going to close this for now, if you find the time to create a reproducible test case please feel free to re-open.

@ellbee ellbee closed this as completed Feb 24, 2016
@gaearon
Copy link

gaearon commented Feb 29, 2016

You might be interested in reduxjs/redux#1455.

@slorber
Copy link
Author

slorber commented Feb 29, 2016

thanks will check that

@gaearon
Copy link

gaearon commented Apr 18, 2016

This is fixed in React Hot Loader 3.
It is built with lessons learned from both React Hot Loader and React Transform.
It’s still in alpha but I encourage you to check it out!

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

No branches or pull requests

3 participants