Comments (8)
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.
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.
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.
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.
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.
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.
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.
A fix for this got merged into React master 11 days ago 🎆
from jsx-control-statements.
Related Issues (20)
- The control statements don't narrow TypeScript types HOT 1
- TypeScript type for children is missing a render function HOT 1
- TChildren conflicts with ReactNode children HOT 2
- Why do we need ```transform-react-inline-elements``` plugin ?
- Switch-case style control statement HOT 2
- Problem with ./node_modules/tsx-control-statements/components.ts HOT 3
- Typo error HOT 1
- Support babel macros HOT 2
- conditional statements don't work unless wrapped in brackets. is this supposed to happen? HOT 1
- Not working with laravel-mix with webpack config
- Can you provide plugins for swc HOT 1
- Can you provide a version based on swc core? HOT 1
- Uncaught ReferenceError: For is not defined HOT 5
- Not working with create-react-app HOT 7
- If is not defined HOT 4
- App breaks if i try to directly access the url - With Error - Choose is not defined HOT 1
- React-Native:Installation-Guide HOT 2
- last published version is 3 years old HOT 2
- ESLint autofix HOT 2
- Undefined is not a function with new JSX transform with react 17 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsx-control-statements.