DEV Community

Raúl Sánchez
Raúl Sánchez

Posted on

2

Named Imports/Exports for React Components

Why named imports/exports?

  • Easier to find references to components
  • Autocomplete
  • Prevents typos

What does a named import look like?

import { Counter } from './Counter';
Enter fullscreen mode Exit fullscreen mode

What does a default import look like?

import Counter from './Counter';
Enter fullscreen mode Exit fullscreen mode

How to export a connected component?

export const _Counter () => {
   ...
}

export const Counter = compose(
   withRouter,
   connect(mapStateToProps, mapDispatchToProps)
)(_Counter);
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️