import React from 'react' import sideEffect from './side-effect' class Head extends React.Component { static contextTypes = { headManager: React.PropTypes.object } render () { return null } } function reduceComponents (components) { return components .map((c) => c.props.children) .filter((c) => !!c) .map((children) => React.Children.toArray(children)) .reduce((a, b) => a.concat(b), []) .reverse() .filter(unique()) .reverse() .map((c) => { const className = (c.className ? c.className + ' ' : '') + 'next-head' return React.cloneElement(c, { className }) }) } function mapOnServer (head) { return head } function onStateChange (head) { if (this.context && this.context.headManager) { this.context.headManager.updateHead(head) } } const METATYPES = ['name', 'httpEquiv', 'charSet', 'itemProp'] // returns a function for filtering head child elements // which shouldn't be duplicated, like