react-redux-firebase: bug(query): remove does not update state when query is applied

Do you want to request a feature or report a bug?

bug

What is the current behavior?

I am facing an issue when events won’t fire when I delete element from my database when firebaseconnect using queryParams. Data in redux is refreshed when creating new data, but upon deletion it stays the same.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via codesandbox or similar.

export default compose(
  connect(
    ({ firebase, router }) => ({
      auth: firebase.auth,
    })
  ),
  firebaseConnect((props, firebase) => {
    return [
      { path: `/organizations`, populates, queryParams: [ `orderByChild=members/${props.auth.uid}`, 'equalTo=true' ] }
    ]
  }
  ),
  connect(
    ({ firebase, router }) => ({
      organizations: firebase.data.organizations,
      isRequesting: firebase.requesting.organizations,
      location: router.location
    })
  )
)(Organizations)

and when I am adding new organization it works fine, eg.

createOrganization(data) {
    this.props.firebase.pushWithMeta('organizations', {
      name: data.name,
      members: {
        [this.props.auth.uid]: true
      },
      owners: {
        [this.props.auth.uid]: true
      },
      projects: []
    }).then((snapshot) => {
      console.log('data pushed', snapshot);
      // this.refs.createOrganizationForm.refs.formsy.reset();
      this.refs.createOrganizationForm.formsyForm.reset();
    });
  }

When creating new organization data in redux is refreshed.

But when I try to delete one, the data in firebase redux isn’t refreshed (until I refresh the page).

deleteOrganization(event, organizationId) {
    event.preventDefault();

    this.props.firebase.remove(`organizations/${organizationId}`).then((snapshot) => {
      console.log('organization removed', snapshot);
    });
  }

What is the expected behavior?

Data in firebase redux key should be updated when deleting.

Which versions of dependencies, and which browser and OS are affected by this issue? Did this work in previous versions or setups?

"react-redux": "^5.0.6",
"react-redux-firebase": "^2.0.0-beta.6",
"react-router-dom": "^4.1.2",
"react-router-redux": "^5.0.0-alpha.6",
"react-scripts": "1.0.10",
"react-test-renderer": "^15.6.1",
"react-three-renderer": "^3.2.1",
"redux": "^3.7.2",
"redux-devtools-extension": "^2.13.2",
"redux-saga": "^0.15.6",

I think that issue is browser/os independent.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 25 (11 by maintainers)

Commits related to this issue

Most upvoted comments

@towfiqi null means that the data is loaded and does not exist. When the value is undefined that means it hasn’t been loaded at all. For folks that have a listener attached on a path that they are deleting, they would see isLoaded(someProps) === false, where you would want to see it equal to true since you do know it is loaded, that path is just empty. With a listener attached, you would then see a flash of it going from value -> undefined -> null.

Open to ideas, just want to make sure we aren’t breaking functionality that others are depending on.

merge: false is not yet supported. The merge parameter is an example of what the syntax may be in the future to support this.

Using dispatchRemoveAction or getting data from ordered instead of data should get things to update as you expect.

@sshadmand You need to update 😄 . The 2 series is on 2.0.0-beta.14 now. You can switch your package file to "react-redux-firebase": "next" if you always want the most up to date version of 2.0.0 (until it is stabilized and released on latest).

Thanks, let me know if I can provide some additional info. Creating data at given path works, but removing doesn’t.

In terms of nested keys I think there is an option 😃 First of all it works for me, and secondly https://firebase.googleblog.com/2015/09/introducing-multi-location-updates-and_86.html (section about Ordering queries by deep paths)