0

I'm trying to use the following react library to create a rich url preview component for my application.

https://docs.microlink.io/sdk/getting-started/react/

In the above documentation there's a working demo, so there's no question about the library. But when i try to use this library i'm getting the following error.

Uncaught (in promise) Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in.

My code

import MicrolinkCard from 'react-microlink'

class Star extends Component {
  render() {
    <MicrolinkCard url='https://www.theverge.com/tldr/2018/2/7/16984284/tesla-space-falcon-heavy-launch-elon-musk'/>
  }
}

I tried changing import MicrolinkCard from 'react-microlink' to import {MicrolinkCard} from 'react-microlink' but still get the same error.

Striped
  • 2,544
  • 3
  • 25
  • 31
CraZyDroiD
  • 6,622
  • 30
  • 95
  • 182

2 Answers2

3
import {MicrolinkCard} from 'react-microlink'

Please check the import thing as well.

 class Star extends Component {

   render() {

      return <MicrolinkCard url='https://google.com'/>

   }

}
Praveen Kumar
  • 1,966
  • 1
  • 9
  • 16
0

you need to return it in your render:

 class Star extends Component {

   render() {

      return <MicrolinkCard url='https://blah.potato'/>

   }

}
Jayce444
  • 8,725
  • 3
  • 27
  • 43
  • Additionally you know the import syntax is right cos it has the documentation. So ensure that the NPM correctly installed and determine where the issue is, i.e. is it where you render the MicrolinkCard component, or where you render the Star component – Jayce444 Apr 24 '18 at 09:30