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

Creating a Checkbox or Modal emits an error in the console when using Preact #1869

Closed
rbscott opened this issue Jul 17, 2017 · 5 comments
Closed

Comments

@rbscott
Copy link

rbscott commented Jul 17, 2017

Steps

  1. Using the preact-cli, build a basic project.
  2. npm install --save semantic-ui-react
  3. Add a simple form with a checkbox element anywhere in the project.
    Sample code:
<Form>
    <Form.Checkbox label='Why the errors?'/>
</Form>
  1. The following errors show up in the console log.
    1. Checkbox is missing "defaultChecked" propTypes validation for auto controlled prop "checked".
    2. Checkbox is missing propTypes validation for auto controlled prop "checked".
    3. Checkbox is missing "defaultIndeterminate" propTypes validation for auto controlled prop "indeterminate".
    4. Checkbox is missing propTypes validation for auto controlled prop "indeterminate".

Expected Result

No errors are emitted.

Actual Result

4 errors are emitted.

Version

0.71.1

Testcase

Repository is pretty barebones, but had to make a separate project in order to demonstrate the issue.
https://github.com/rbscott/auto-controlled-error

Notes

I am not sure if Preact is official supported, but it seems to mostly work. If someone points me in the right direction, I could put together a Pull Request.

@layershifter
Copy link
Member

@rbscott Thanks for report. However, you're right, PReact isn't officially supported. Help there is much appreciated. Warnings are come from AutoControlledComponent, but issue is quite strange.

@levithomason
Copy link
Member

PRs increasing interop with other libraries are very much welcomed. Closing for housekeeping as there are no errors with React and this library is intended to be used with React only.

@levithomason
Copy link
Member

In case it is of help, these are errors for developers that are only logged when NODE_ENV !== 'production'. We check that the Component.constructor.propTypes include the necessary keys for the component. Preact must be doing something to the propTypes so that some are missing. Namely, the default* propType for checked and indeterminate.

@rbscott
Copy link
Author

rbscott commented Jul 25, 2017

@levithomason thanks for the info. It looks like preact removes prop types for all builds. There is a PR to change this behavior so it only removes propTypes during production builds. I believe this will resolve this issue.

@brianjd
Copy link
Contributor

brianjd commented Jul 27, 2017

@rbscott preact-compat is the solution you are looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants