Bug when using forceUpdate (or observable libraries)
nightwolfz opened this issue · 8 comments
How to reproduce:
import Inferno from 'inferno'
import Component from 'inferno-component'
class Wrapper extends Component {
componentDidMount() {
this.hidden = true
this.forceUpdate()
}
render() {
return <Test hidden={this.hidden}/>
}
}
class Test extends Component {
render() {
console.warn('hidden', this.props.hidden)
if (this.props.hidden) {
return null
}
return <div>
Test
</div>
}
}
export default Wrapper
This will throw an exception:
inferno-dom.js:337 Uncaught (in promise) TypeError: Cannot read property 'replaceChild' of null(…)
replaceNode @ inferno-dom.js:337
patch @ inferno-dom.js:867
patchComponent @ inferno-dom.js:1382
patchVNodeWithBlueprint @ inferno-dom.js:1026
patchVNode @ inferno-dom.js:978
patch @ inferno-dom.js:883
applyState @ inferno-component.js:153
forceUpdate @ inferno-component.js:198
componentDidMount @ Test.js:8
mountComponent @ inferno-dom.js:787
mountArrayChildren @ inferno-dom.js:725
mountChildren @ inferno-dom.js:732
mountVNodeWithBlueprint @ inferno-dom.js:640
mountComponent @ inferno-dom.js:785
mountComponent @ inferno-dom.js:785
mountArrayChildren @ inferno-dom.js:725
mountChildren @ inferno-dom.js:732
mountVNodeWithBlueprint @ inferno-dom.js:640
mountComponent @ inferno-dom.js:785
mountComponent @ inferno-dom.js:785
mountComponent @ inferno-dom.js:785
render @ inferno-dom.js:2013
@nightwolfz Can you see if this happens in dev
branch – as lots has changed from 0.7 to 1.0? Thank you :)
@trueadm Ok I'll give it a try. I have no clue how to setup your project though.
Just doing npm link doesn't seem to work. Can't define github subdirectories in packages.json either.
Copy paste generated bundles I guess.
Hey @nightwolfz I'm struggling with this same issue trying to link to latest Dev, haven't found nice way to do it yet. however if you want to test with latest published version you can do it simply by changing package.json to
"devDependencies": {
"babel-plugin-inferno": "^1.0.0-alpha8",
"inferno": "^1.0.0-alpha8",
"inferno-component": "^1.0.0-alpha8",
"inferno-dom": "^1.0.0-alpha8"
}
@Havunen @nightwolfz Inferno uses a monorepo, so you can't use git
URLs to pull in content, as that would require a repo per package. What I do is symlink your local inferno
repo's packages/inferno/dist
directory into your local node_modules/inferno/dist
. Works perfectly fine on Linux/OS X. I believe Windows users can now use symlinks via the micro Linux kernel on Windows 10, otherwise you might be able to use shortcuts somehow (sorry, I don't use Windows).
Alternatively, we could look into using something like Lerna - https://github.com/lerna/lerna and changing the current Inferno monerepo into something that is more mainstream. Ideas?
NTFS has always had support for symlinks, junctions, hardlinks, but you have to use cmd to create them. If you want a shell extension / gui for doing this, try http://schinagl.priv.at/nt/hardlinkshellext/linkshellextension.html
With @Havunen 's help I managed to setup the dev branch. Good news is that the issue is gone now!
The "bad news" is that I have to update mobx-inferno now, which I'll gladly do! :D
@nightwolfz awesome :)