-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix named export for example components #1380
Conversation
iss: styleguidist#1281 Updated examples-loader to import component with named export Named export of Basic button is not working, but CounterButton is now falling with an error: ``` Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of `FunctionComponentWrapper`. ```
Ok, I finally get the idea why with this fix we have problems with other components from example. First example: CounterButton.Markdown code for CounterButton looks like this import Button from '../Button'
let ref
;<div>
<CounterButton ref={r => (ref = r)} />
<Button size="small" onClick={() => ref.set(0)}>
Reset
</Button>
</div> The error is about this import Second example: was tricked by itimport React from 'react'
import Button from 'rsg-example/components/Button'
import Placeholder from 'rsg-example/components/Placeholder'
;<Button>
<Placeholder />
</Button> In this case I had error with It's the same button component, and we should import it in the same way with named import. |
I thinks that ast bulder code update I'm going to remove WIP code and update tests. |
Added new version of expected require for named export case
I've finally updated the PR. It's ready for review. I'm wondering does it make sense to add named export to some basic example code, just to have this case in examples? |
Haha, this all sounds very familiar! ;-) And thanks for fixing so many things in Styleguidist!
Yeah, that would make sense — tests aren't always enough to make sure things are still working. |
Had to break "prefer default export" rule
You are welcome! I found the code pretty interesting and clear. So it's a kind of pleasure to debug 🙂. I haven't used it yet. But definitely will. And all this design system area looks inspiring.
I've updated the PR. Added such kind of import into RandomButton, so it likely hurt anyone who uses somehow example/basic components. Any other suggestions? @sapegin |
Codecov Report
|
Thanks! 🦄 |
🎉 This PR is included in version 9.1.6 🎉 The release is available on: Your semantic-release bot 📦🚀 |
iss: #1281
Updated examples-loader to import component with named export
Named export of Basic button is now working
I tried suggestion
const name = name$0[name] || name$0.default || name$0;
CounterButton component is now falling with an error:
Placeholder from my previous report is now working.