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

Partial Store Shadowing #6

Open
objectliteral opened this issue May 15, 2019 · 0 comments
Open

Partial Store Shadowing #6

objectliteral opened this issue May 15, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@objectliteral
Copy link
Contributor

Currently a component with state interacts with the closest store that is connect to on of the component's ancestors. This is probably what the user wants in some cases, but it is a all-or-nothing: None of the keys from other stores are available.

Expectation: It would be nice, if the closer store does not completely shadow others, but that the shadowing takes place on the level of individual keys.

Example

const Child = withState('foo')(({foo, answer}) => {
    return (
        <div>{`foo: ${foo} and answer: ${answer}`}</div>
    );
});

const Father = connect(() => {
    return (
        <Child />
    )
}, { foo: 'bazzz' });

const App = () => {
    return (
        <Father>
            <Child />
        </Father>
    )
}

const Grandfather = connect(App, { foo: 'bar', answer: 42 });

This currently renders "foo: bazzz and answer: undefined" because Child only has access to the nearest store. With partial store shadowing, this example should render "foo: bazzz and answer: 42".

@objectliteral objectliteral added the enhancement New feature or request label May 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant