Giter Club home page Giter Club logo

Comments (8)

tomitrescak avatar tomitrescak commented on May 19, 2024

In ast.js I changed

if (!blocks.length) {
    return babelTypes.NullLiteral();
  }

to

if (!blocks.length) {
    return babelTypes.BooleanLiteral(false);
  }

And all works in hot module reload AND in react tools.
I think there is no harm in returning false instead of null.

Would you consider adding this to the core? Or at least somehow have the possibility to specify which literal can be returned as a "null" literal.

[EDIT] Same needs to be updated in choose statement:

  if (!result[ELEMENTS.OTHERWISE]) {
    result[ELEMENTS.OTHERWISE] = types.BooleanLiteral(false);
  }

from jsx-control-statements.

AlexGilleran avatar AlexGilleran commented on May 19, 2024

Ah man, we only just changed to to null in #17!

Returning false appears to be fine according to https://facebook.github.io/react/docs/component-specs.html so I guess we can do it. Weird that null breaks it though.

Can you make a PR with what you've done? :)

from jsx-control-statements.

jimfb avatar jimfb commented on May 19, 2024

Returning null should work, as per the spec. If there are situations where null breaks something, that should be fixed upstream. Returning null seems like the best thing to do. Returning undefined would also be fine. Returning false is slightly less good, but could work.

Honestly, I would just close this as "won't fix", and ask people to file bugs on the libraries/tools. jsx-control-statements is completely within spec on this point, afaik. Playing whack-a-mole with bugs in other systems is not a sustainable solution.

from jsx-control-statements.

tomitrescak avatar tomitrescak commented on May 19, 2024

null breaks it in several different packages ... if changing it to false or undefined will have only positive effects, not sure why it should not be fixed? I'll prepare PR soon, am currently on my way to Europe, so I'll do that ASAP.

from jsx-control-statements.

AlexGilleran avatar AlexGilleran commented on May 19, 2024

Depends if changing it to false fixes this and creates some kind of equivalent obscure problem in something else ;).

What @jimfb says makes sense but I think we should at least support a fork until the underlying issue is fixed.

from jsx-control-statements.

tomitrescak avatar tomitrescak commented on May 19, 2024

I'm open to anything, am running from my fork anyways, I only asked if you would consider bringing this into the core. If not, it's perfectly fine and I'll just update from git to latest version when needed.

from jsx-control-statements.

texttechne avatar texttechne commented on May 19, 2024

Switching to undefined would be fine IMHO. But @tomitrescak are you sure that this will fix the issue? As far as I can tell from the mentioned issues this wasn't a proposed solution. So have you tested this approach?

I would really consider doing this, since in my experience such nasty browser bugs get rarely fixed by browser maintainers.

from jsx-control-statements.

AlexGilleran avatar AlexGilleran commented on May 19, 2024

A fix for this got merged into React master 11 days ago 🎆

facebook/react-devtools#198

from jsx-control-statements.

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.