Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can I add a local icon png in the Tab ? #3111

Closed
radjivF opened this issue Jul 3, 2018 · 4 comments
Closed

how can I add a local icon png in the Tab ? #3111

radjivF opened this issue Jul 3, 2018 · 4 comments

Comments

@radjivF
Copy link

radjivF commented Jul 3, 2018

Version

Tell us which versions you are using:

  • react-native-router-flux ^4.0.0-beta.31 (v3 is not supported)
  • react-native 0.55.4

Expected behaviour

Im trying to get an image in a tab and not an icon and its been very hard, how can I did this

import formIcon from '../assets/form-icon.png'
import checkboxIcon from '../assets/checkbox-icon.png'
import personIcon from '../assets/person-icon.png'


const TabIcon = ({ selected, title }) => {
  let image

  switch (title) {
    case 'Forms':
      image = formIcon
      break
    case 'Actions':
      image = checkboxIcon
      break
    default:
      image = personIcon
  }
  return (<Image source={image} />)
}

Actual behaviour

I get an error

Invariant Violation: element type is invalid: expected a string (for build component) or a class/function but got undefined

Check the render Method of 'TabIcon'

Any idea how can I add a local icon png in the Tab

Im totally lost at the moment. Thanks for your help

@ekoooo
Copy link

ekoooo commented Jul 3, 2018

e.g. image = require('../assets/form-icon.png');

@radjivF
Copy link
Author

radjivF commented Jul 3, 2018

thx @ekoooo, but unfortunately I have tried this too and I get

Violation: 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, or you might have mixed up default and named imports.

Check the render method of TabIcon.

@jcoulaud
Copy link

thx @ekoooo, but unfortunately I have tried this too and I get

Violation: 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, or you might have mixed up default and named imports.

Check the render method of TabIcon.

I had the same thing when using the Image component from React Native Elements. Switched to the Image component from React Native and it fixed the problem ;)

@aksonov
Copy link
Owner

aksonov commented Aug 8, 2018

@jcoulaud is right, closing this issue.

@aksonov aksonov closed this as completed Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants