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

Dictionary not updating on data change with @realm/react #5182

Closed
mohammadhunan-dev opened this issue Dec 15, 2022 · 2 comments
Closed

Dictionary not updating on data change with @realm/react #5182

mohammadhunan-dev opened this issue Dec 15, 2022 · 2 comments
Assignees
Labels

Comments

@mohammadhunan-dev
Copy link

mohammadhunan-dev commented Dec 15, 2022

How frequently does the bug occur?

Seen once

Description

Hi,

I'm having issues with the Realm.Dictionary type where I'm trying to render data about the dictionary to the UI. However, when the data changes, the component doesn't rerender.

Consider the following scenario that would have the UI update if the task's name or priority changed:

const TaskItem = ({_id}: {_id: number}) => {
  const myTask = useObject(Task, _id);
  return (
    <View>
      {myTask ? (
        <Text>
          {myTask.name} is a task with the priority of: {myTask.priority}
        </Text>
      ) : null}
    </View>
  );
};

Alternatively, consider this scenario where if the home.address changed, the UI wouldn't re-render:

const HomeList = () => {
  const realm = useRealm();
  // query for all HomeOwner objects
  const homeOwners = realm.objects(HomeOwner);

  return (
    <View>
      <Text>All homes:</Text>
      {homeOwners.map(homeOwner => (
        <View>
          <Text>{homeOwner.home.address}</Text>
        </View>
      ))}
    </View>
  );
};

Stacktrace & log output

No response

Can you reproduce the bug?

Yes, always

Reproduction Steps

No response

Version

@realm/react: ^0.4.1; realm: ^11.0.0

What SDK flavour are you using?

Local Database only

Are you using encryption?

No, not using encryption

Platform OS and version(s)

macOS 12.6.1 (Monterey)

Build environment

Which debugger for React Native: ..
Running this in a test environment with jest and react native testing library, you can see that environment here: https://github.com/mongodb/docs-realm/tree/master/examples/react-native

Cocoapods version

No response

@kneth
Copy link
Contributor

kneth commented Dec 19, 2022

@mongomoe Thank you for reporting. I wonder if is it related to #5185, and we need to investigate it further.

Copy link

sync-by-unito bot commented Jan 15, 2024

➤ takameyer commented:

Solved with the keypath feature.

@sync-by-unito sync-by-unito bot closed this as completed Jan 15, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants