Skip to content

Instantly share code, notes, and snippets.

@ManasJayanth
Created July 8, 2018 15:21
Show Gist options
  • Save ManasJayanth/741b3b4ee80425c29c67166c78e33af0 to your computer and use it in GitHub Desktop.
Save ManasJayanth/741b3b4ee80425c29c67166c78e33af0 to your computer and use it in GitHub Desktop.
finalizeInitialChildren(
domElement,
type,
props,
rootContainerInstance,
hostContext
) {
const { children, ...otherProps } = props;
Object.keys(otherProps).forEach(attr => {
if (attr === 'className') {
domElement.class = otherProps[attr];
} else if (attr === 'onClick') {
const listener = otherProps[attr];
if (domElement.__ourVeryHackCacheOfEventListeners) {
domElement.__ourVeryHackCacheOfEventListeners.push(listener)
} else {
domElement.__ourVeryHackCacheOfEventListeners = [ listener ]
}
domElement.addEventListener('click', listener);
} else {
throw new Error('TODO: We haven\'t handled other properties/attributes')
}
})
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment