Sandeep Arora
Sandeep Arora

Reputation: 5

How to fix, Module has no exported member in react component?

I am creating a web part using spfx with react.js. I have created a new component and I am getting 'Module has no exported member' while importing this newly created component. How to fix this issue?

    import Form from 'react-validation/build/form';
    import Input from 'react-validation/build/input';
    import Button from 'react-validation/build/input';
    import * as React from 'react';
    import validator from 'validator';
    const required = (value) => {
    if (!value.toString().trim().length) {
      // We can return string or jsx as the 'error' prop for the validated 
     Component
      return 'require';
    }
    };
    const email = (value) => {
    if (!validator.isEmail(value)) {
      return `${value} is not a valid email.`
    }
  };
  export default class NewForm extends React.Component {
    render() {
        return <h3>Hello</h3>
    }
}

And below is import;

import { NewForm } from '../components/NewForm'

Upvotes: 0

Views: 12101

Answers (2)

Mahamudul Hasan
Mahamudul Hasan

Reputation: 494

Try changing it to

import NewForm from '../components/NewForm'

Upvotes: 0

Corentin Mors
Corentin Mors

Reputation: 61

You should use :

import NewForm from '../components/NewForm'

because it's a default import.

See this thread : https://stackoverflow.com/a/34841313/8649904

Upvotes: 6

Related Questions