Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

It's not working for me. Thrown error: Expected a class but got undefined #28

Open
VanessaChu opened this issue Apr 15, 2018 · 1 comment

Comments

@VanessaChu
Copy link

I did tried 2 ways:

CancelSvg.js

import React from 'react'
import Svg, { Line } from 'react-native-svg'

export default class CancelSvg extends React.Component {
  render () {
    return (
      <Svg height='50' width='50'>
        <Line x1={37.5} x2={12.5} y1={12.5} y2={37.5} strokeWidth='2.5' stroke={'#fff'} />
        <Line x1={12.5} x2={37.5} y1={12.5} y2={37.5} strokeWidth='2.5' stroke={'#fff'} />
      </Svg>
    )
  }
}

MenuSvg.js

import React from 'react'
import Svg, { Line } from 'react-native-svg'

export default class MenuSvg extends React.Component {
  render () {
    return (
      <Svg height='50' width='50'>
        <Line x1={10} x2={40} y1={15} y2={15} strokeWidth='2.5' stroke={'#fff'} />
        <Line x1={10} x2={40} y1={25} y2={25} strokeWidth='2.5' stroke={'#fff'} />
        <Line x1={10} x2={40} y1={35} y2={35} strokeWidth='2.5' stroke={'#fff'} />
      </Svg>
    )
  }
}

Main.js

                <MorphReplaceNative width={60} height={60}>
                  {
                    this.state.showMenu ? <MenuSvg /> : <CancelSvg />
                  }
                </MorphReplaceNative>

Error: Expected a class but got undefined. You likely forgot to export your Component from the file it's defined.

But I did export it. I also tried replacing with in MenuSvg.js and CancelSvg.js but it's not working.

@isaaclem
Copy link

Did you imported MenuSvg and CancelSvg in your Main.js?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants