0

java

<ActivityBadgesComponent
                      badgeImage={
                        item.completed
                          ? require('../images/ic_' + item.game_level.toLowerCase() + '_active.png')
                          : require(`../images/ic_${item.game_level.toLowerCase()}_inactive.png`)
                      }
                    />

P.S -> I have also tried giving the values withing string.

require(`../images/ic_${item.game_level.toLowerCase()}_active.png`)

This also didn't work.

In my require function I am trying to give some dynamic string to the image depending on the value but it can't load. When I give some static values then it works perfectly.

ActivityBadgesComponent.js

  <Image
            source={this.props.badgeImage}/>
Pingolin
  • 3,161
  • 6
  • 25
  • 40
Rishav Kumar
  • 4,979
  • 1
  • 17
  • 32

0 Answers0