question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why not also export `carbon-components-react` components?

See original GitHub issue

Summary

Right now components from carbon-components-react are passed through the mdx provider so that they can be used in .mdx files without having to add carbon-components-react as a dependency. However, those components are not exported.

If a consumer is trying to use any Carbon react components (alongside this theme’s components) in a new component they are creating in a .js file in their downstream site, there’s no way to utilize something from carbon-components-react unless the consumer adds that library as an additional dependency.

So you can have a situation where you are using one version of carbon-components-react in mdx files, and then another version of carbon-components-react if you have to add it as a dependency in order to import something into a .js to create your own component, for example, to use your site.

So my question is – why not export all components (that make sense to export) from carbon-components-react?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jendownscommented, Jan 30, 2020

@vpicone Yeah that’s what I was thinking… but in the case where you all have redefined/changed a carbon component in some way, I think it would make sense to export that variation instead, like with the Tabs (i.e., export your Tabs and not the ccr Tabs, to avoid the overlap).

1reaction
jendownscommented, Jan 24, 2020

Okay just tried to experiment with this and I’m not getting ideal results…

Imagine this structure:

- my-components
  - CustomComponent.js
- pages
  - index.mdx

If I want to import StructuredList from carbon-components-react into my CustomComponent.js, I must add carbon-components-react as a dependency and import from there, otherwise I get a big error and the page breaks.

If I want import StructuredList into my index.mdx, I also still have to add carbon-components-react as a dependency and add import statements at the top of the file. If I don’t and if I just try to use StructuredList with no import, the page build won’t fail but the component won’t be there.

Either way, whether using a Carbon component in a js or mdx file, it appears as though I need to add carbon-components-rect as a dependency and import the component from there. 🤔

Read more comments on GitHub >

github_iconTop Results From Across the Web

Guide - Carbon Design System
They are also re-exported through @carbon/react. Both the carbon-components and carbon-components-react packages will stick around in v11 but they will only ...
Read more >
Export - Carbon Design System
When a resource is given an intuitive name by default and there is no choice of an export or download location, the export...
Read more >
1. Installing Carbon
This tutorial will guide you in creating a React app with the Carbon Design System. ... In src/components/TutorialHeader/index.js , import and export our ......
Read more >
4. Creating components - Carbon Design System
This tutorial will guide you in creating a React app with the Carbon Design ... Since Info.js will export multiple components, we'll use...
Read more >
1. Installing Carbon – Carbon Design System
Starting with Create React App, let's install Carbon and begin using Carbon components. By the end you will have a React app that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found