developit / preact-redux-example

:repeat: Preact + Redux Example Project
https://preact-redux-example.surge.sh
199 stars 53 forks source link

Redundant dependencies? #2

Closed pinn3 closed 8 years ago

pinn3 commented 8 years ago

Might have missed some but, if I'm not mistaking, the following packages are redundant. Not sure if you left them there for boiler purposes though

babel-preset-es2015@package.json:27 Since you only use es2015-minimal

preact-compat@package.json:53 and react@package.json:56 Because you never seem to use anything from the react package

preact-router@package.json:54 Never used

Also, kind of off topic, regarding the last one; I've tried to implement redux in my own preact app with react-redux and preact-router, but the Provider component is complaining about its children, which are the Router component with its children:

invariant.js:38Uncaught Invariant Violation: onlyChild must be passed a children with exactly one child.
    invariant @ invariant.js:38
    onlyChild @ onlyChild.js:29
    render @ Provider.js:53
    hook @ preact.js:65
    renderComponent @ preact.js:379
    createComponentFromVNode @ preact.js:44
    8buildComponentFromVNode @ preact.js:435
    diff @ preact.js:226
    render @ preact.js:478
    80../config/routes @ index.js:24
    s @ _prelude.js:1
    e @ _prelude.js:1
    (anonymous function) @ _prelude.js:1

Any clue?

katopz commented 8 years ago

I'm curios too and also get that error when I try to add undo/redo too. @developit any hint please?

developit commented 8 years ago

The Babel presets are correct: minimal specifies the normal es2015 preset as a peerDependency so it can be updated independently.

Will look into this asap. In React a single child is not wrapped in an array, which preact-compat attempts to emulate.

developit commented 8 years ago

Ah - I forgot to close this out when I switched the project to preact-redux. That fixed the unnecessary dependencies. The minimal preset is required as I mentioned above, so it looks like this can be closed!

abeaclark commented 8 years ago

Does preact-redux fix this problem? Having the same issue

Provider component is complaining about its children, which are the Router component with its children

Thanks.

pinn3 commented 8 years ago

Yup, preact-redux does the trick

developit commented 8 years ago

Awesome, thanks guys!