developit / preact-redux

:loop: Preact integration for Redux (no shim needed!)
https://npm.im/preact-redux
MIT License
288 stars 27 forks source link

Preact X, preact-redux is not working.. #42

Open ohute-couture opened 5 years ago

ohute-couture commented 5 years ago

Preact, 10.0.0-alpha.2 preact-redux is not working, react-redux work properly image There is No Error, Just There is <Provider/> without children(<App/>) Check Plz

Sexual commented 5 years ago

Can confirm this is also occurring with our app, but not sure how to replicate it at the moment.

ohmoses commented 5 years ago

The problem seems to be that in Preact X, props.children is no longer guaranteed to be an array, and in this case, if you're passsing a single child, props.children is a VNode.

There's this in src/compat.js:

export const Children = {
    only(children) {
        return children && children[0] || null;
    }
};

Here children[0] doesn't exist. Should be something like

export const Children = {
    only(children) {
        if (Array.isArray(children))
            return children[0]
        else if (children && typeof children === "object")
            return children
        else
            return null
    }
};
developit commented 5 years ago

For those working with X, try using react-redux and preact/compat. Hopefully this will be fixed soon.

fjorgemota commented 5 years ago

Hey!

Could you guys test preact-redux's master?

I suspect that my PR, #41, fixes the problems related to Preact Redux but I'm not 100% sure of that, and the test suites would need to be adapted to support Preact X..(so breaking the compatibility with Preact 8), which I will try to fix in the next weeks.

WaqarHassan commented 5 years ago

@fjorgemota Any Updates regarding the fix. I can't use react-bootstrap4-modal package with preact-redux. It works fine without connect.

fjorgemota commented 4 years ago

To anyone interested on this issue: could you test if the PR #48 works for you?

When merged that PR should fix this issue, I think.