Git Product home page Git Product logo

Comments (5)

robertknight avatar robertknight commented on May 18, 2024 2

After some debugging, it looks like picostyle is subtly broken with Preact 10.

When the wrapper component is rendered, it is called with two arguments: props and context, where context defaults to an empty object ({}). The place where Preact calls the picostyle component's render function is here: https://github.com/preactjs/preact/blob/984f18dc20cc7a2ec3cd30f29c25aac0c53dbca0/src/diff/index.js#L311

Picostyle however expects the render function to be called with the second argument being the children of the component, not the context. This should be an element, string or array. See https://github.com/morishitter/picostyle/blob/9f4053f806adbedbd7ee916e42f8153fbaccd948/src/index.js#L57

The result is that an invalid vnode gets generated which later trips up the Enzyme adapter, and probably breaks other things as well.

The error can be reproduced without Picostyle using:

import { h } from "preact";
import { configure, mount } from "enzyme";
import { Adapter } from "enzyme-adapter-preact-pure";

function App() {
  return h('div', {}, {} /* Not a valid `children` argument */);
}

configure({ adapter: new Adapter() });

mount(<App />);

The preact/debug package could potentially catch this error when h is called and warn the developer about it. In the meantime, since the problem is not an issue with the adapter itself, I'm going to close this issue. If you could report it upstream to the Picostyle author, that would be appreciated.

from enzyme-adapter-preact-pure.

robertknight avatar robertknight commented on May 18, 2024 1

Hello @samueljseay, I created a quick test on CodeSandbox using Preact 10, picostyle and Enzyme but was unable to reproduce the issue.

Can you please create a minimal project that reproduces the problem, either as a Code Sandbox, GitHub repo or Gist and post the link here.

from enzyme-adapter-preact-pure.

samueljseay avatar samueljseay commented on May 18, 2024 1

Thanks all! I will raise this on picostyle!

from enzyme-adapter-preact-pure.

samueljseay avatar samueljseay commented on May 18, 2024

@robertknight I was able to reproduce it with your example, just mount the picostyle node directly: https://codesandbox.io/s/preact-picostyle-enzyme-ctifh

from enzyme-adapter-preact-pure.

marvinhagemeister avatar marvinhagemeister commented on May 18, 2024

Yeah that function signature in picostyle is wrong. The second argument has never been children, even for other libraries as far as I can tell.

from enzyme-adapter-preact-pure.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.