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

React Redux 丐中丐版 #11

Open
n3taway opened this issue Apr 13, 2021 · 0 comments
Open

React Redux 丐中丐版 #11

n3taway opened this issue Apr 13, 2021 · 0 comments

Comments

@n3taway
Copy link
Owner

n3taway commented Apr 13, 2021

const store = {
    data: { name: 'jsx' },
    getData() {
        return this.data;
    }
};

function connect(_mapToPropsFn) {
    const dataFromStore = store.getData();
    const selectData = _mapToPropsFn(dataFromStore);
    return function (_component) {
        return _component(selectData)
    };
};

function divComponent(props) {
    return `<div>${JSON.stringify(props)}</div>`
}

const component = connect((store) => {
    return { ...store, age: 12 };
})(divComponent);

console.log('component: ', component); // component: <div>{"name":"jsx","age":12}</div>

// document.body.innerHTML = component;
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

1 participant