0 votes
in ReactJS by

How to import and export components using React and ES6?

1 Answer

0 votes
by

You should use default for exporting the components

import React from 'react'
import User from 'user'

export default class MyProfile extends React.Component {
  render(){
    return (
      <User type="customer">
        //...
      </User>
    )
  }
}

With the export specifier, the MyProfile is going to be the member and exported to this module and the same can be imported without mentioning the name in other components.

Related questions

0 votes
asked Feb 24, 2021 in ReactJS by SakshiSharma
0 votes
asked Jan 30, 2021 in ReactJS by rajeshsharma
...