import React from 'react'
import hashsum from 'hash-sum'

export default function phash(_props) {
  const props = Object.keys(_props).reduce((acc, key) => {
    const prop = _props[key]

    if (key == '__flint')
      return acc

    if (prop instanceof Object && prop.hashCode)
      acc[key] = prop.hashCode()

    // TODO: traverse children
    else if (React.isValidElement(prop))
      acc[key] = prop.key

    else
      acc[key] = prop

    return acc
  }, {})

  return hashsum(props)
}

@@ -55,47 +55,168 @@
 m'%0A%0A
-export default function phash(_props) %7B
+const disableHashing = /%5C?nohash/.test(window.location.search)%0A%0Aexport default function phash(_props) %7B%0A  if (disableHashing)%0A    return hashsum(Math.random())%0A
 %0A  c

add disable option