First of all, I think React DOM is one of the most interesting part in React code base. I’m not sure if it is correct but whatever, stop thinking and start diving.
This is the React-DOM test file at the time I’m writing this post. If you find latest version is different from what mentioned in this post please feel free to make a PR.
ReactDOM
should bubble onSubmit
So we can listen anonsubmit
event on adiv
. That’s crazy right? Most of the time we only listen this event on aform
but in fact any tag can listen to this event if it has a form children.should overwrite props.children with children argument
So for example if we have<Component children={'real'}>fake</Component>
. We will getfake
as result.throws in render() if the update callback is not a function
ReactDOM.render
supports an optionalcallback
parameters to be called after component is mounted into container. I look for actual implementation and find it callbackfiberRoot
instance asthis
. So you canconsole.log(this.nodeName)
ReactMount
should unmount and remount if the key changes
I have known this beavior of React key before, but it’s interesting to see it actually documented in the test.