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

[Improvement] Add the ability to join keys in withOnyx #176

Open
arosiclair opened this issue Sep 13, 2022 · 0 comments
Open

[Improvement] Add the ability to join keys in withOnyx #176

arosiclair opened this issue Sep 13, 2022 · 0 comments

Comments

@arosiclair
Copy link
Contributor

Problem
Coming from this discussion.

It's not currently possible to subscribe to keys relationally. So to join one key to another key in a collection we must subscribe to the key and the entire collection and then find the linked key manually like this

class Component {
    render() {
        this.linkedKey = this.props.collectionB.find(itemB => itemB.ID === this.props.itemA.bID);
        // ...
    }
}

export default withOnyx({
    itemA: {
        key: 'ITEM_A_KEY',
    },
    collectionB: {
        key: 'COLLECTION_B',
    },
})(Component);

Solution
Add the ability to accomplish this join in withOnyx directly so we don't need to write search code to link two keys together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant