GithubHelp home page GithubHelp logo

Comments (5)

jasperkuperus avatar jasperkuperus commented on April 25, 2024 1

@jeanlauliac Is it an idea to add a better error if someone does use @2x and then refer to this issue?

from metro.

jeanlauliac avatar jeanlauliac commented on April 25, 2024 1

Yes, a specific error message sounds good to me. I would not refer to this issue though, I'd just mention that removing the scale specifier solves the problem.

from metro.

cpojer avatar cpojer commented on April 25, 2024

@jeanlauliac knows about assets.

from metro.

jeanlauliac avatar jeanlauliac commented on April 25, 2024

Sorry I've been lagging behind quite a lot.

About this issue: in Metro, assets are not meant to be required with a specific scale, since different devices might use different scales. In that example, requiring ./myImage.png would cause either [email protected] or [email protected] to be used depending on the device screen pixel ratio (virtual-pixel to physical-pixel ratio, so to speak).

@mo-solnet can you explain what is the benefit of using require('../[email protected]') over require('../myImage.png')?

from metro.

jeanlauliac avatar jeanlauliac commented on April 25, 2024

I haven't got the time to try to fit a hint message somewhere in the stack, but I'll close this issue for now, as this is the expected behaviour, and scale specifiers should not be included in the name when requiring assets. Do feel free to send a PR to tweak error messages however.

The documentation mentions having different densities and does have the example without the density specifier, so I don't think it needs updating? (https://facebook.github.io/react-native/docs/images.html#static-image-resources)

from metro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.