1

I'm referring to the image via require and I wanted to crop the icons from the sprite image.

const sprite = require('./sprite.png')
const crop = {left: 10, top: 50, width: 20, height: 40}

export const cartLogo = sprite({crop})
// How do I apply the crop to the sprite?

then

<Image source={cartLogo}/>

I see how to crop the image in react-native when using {uri: 'url-to-image', crop: {left: 10, top: 50, width: 20, height: 40}} in here. How to do it with require?.

nabeel
  • 1,181
  • 2
  • 10
  • 24

1 Answers1

0

I know that require('./sprite.png') will be depreciated soon.

So the best way it's to managed it with

image : {uri: ..., crop: {left: 10, top: 50, width: 20, height: 40}}

You can also follow my post here.

let us know if you success

Community
  • 1
  • 1
G Clovs
  • 2,442
  • 3
  • 19
  • 24
  • Was `require('./sprite.png')` ever deprecated? I'm not sure how to use your answer. Is this a property of ``? I've read your post, which references the docs, which don't give any examples of how to use it (the use of `static` confuses me). – mrmicrowaveoven Sep 20 '20 at 22:52