Created
July 8, 2018 15:21
-
-
Save ManasJayanth/741b3b4ee80425c29c67166c78e33af0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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