Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inferno4 {0} not rendered in DOM #1292

Closed
kurdin opened this issue Feb 28, 2018 · 6 comments
Closed

inferno4 {0} not rendered in DOM #1292

kurdin opened this issue Feb 28, 2018 · 6 comments
Labels

Comments

@kurdin
Copy link
Contributor

kurdin commented Feb 28, 2018

Not sure why I have this problem but I have pager component with variable z === 0 it was renders fine in DOM in inferno3. Now after inferno4 upgrade I need to add {variable + ''} to make sure 0 is visible.

Strange thing that I could not reproduce this on here: https://jsfiddle.net/vrydxohy/
and React 16 renders 0 just fine: https://jsfiddle.net/sfbg7eL3/

Who is responsible for not rendering 0 into DOM HTML ? it does not look like inferno4 problem and I use latest babel-plugin-inferno and babel-plugin-syntax-jsx packages.

@Havunen
Copy link
Member

Havunen commented Mar 1, 2018

I have never seen this before. We need steps to reproduce to be able to identify the issue.

@kurdin
Copy link
Contributor Author

kurdin commented Mar 1, 2018

@Havunen
After few hours of digging thru few handers of files in our app, I finally found the problem.

We use inferno-compat in few places for findDOMNode and React.cloneElement in packages that we converted from react. So it turns out if you simple import inferno-compat anywhere in your app along with inferno then {0} wont be rendered in DOM in any component of app. Strange but looks like a bug in inferno-compat.

Here is example, I just included inferno-compat via script and {0} wont work anymore.

https://jsfiddle.net/nLjoyfe2/

@Havunen
Copy link
Member

Havunen commented Mar 1, 2018

Yeah this is bug, also there seems to be performance issue in inferno-compat. It seems like in inferno-compat arrays fall into iterableToArray code path as arrays are iterables too. Need to fix that. The actual bug is also there:

https://github.com/infernojs/inferno/blob/master/packages/inferno-compat/src/index.ts#L192-L194

Let's hotfix this.

@Havunen Havunen added the bug label Mar 1, 2018
@kurdin
Copy link
Contributor Author

kurdin commented Mar 1, 2018

@Havunen We trying to avoid using inferno-compat but sometimes it is quicker to convert some functionality from React.

What would be alternative for React.cloneElement in inferno4 ?

@Havunen
Copy link
Member

Havunen commented Mar 1, 2018

@kurdin

It depends: if all you want is clone and assign props, then you can use const copy = Inferno.directClone(vNode); and maybe Object.assign props into copied vNode. If you want same API then you can use inferno-clone-vnode package its drop in replacement

Havunen added a commit that referenced this issue Mar 1, 2018
… not rendering falsy text values (0 and empty string). Github #1292
@Havunen
Copy link
Member

Havunen commented Mar 1, 2018

Just released 4.0.7 this is fixed there. Thanks for reporting the issue. Closing

@Havunen Havunen closed this as completed Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants