diff --git a/Example/examples/G.js b/Example/examples/G.js index a5b5a12d..c6aab772 100644 --- a/Example/examples/G.js +++ b/Example/examples/G.js @@ -23,10 +23,12 @@ class GExample extends Component{ stroke="pink" strokeWidth="3" > - + + + - + + + + + ; } } diff --git a/elements/G.js b/elements/G.js index 17e22912..05c5d76d 100644 --- a/elements/G.js +++ b/elements/G.js @@ -10,6 +10,11 @@ import extractProps from '../lib/extract/extractProps'; class G extends Component{ static displayName = 'G'; + static contextTypes = { + svgId: numberProp, + ...contextProps + }; + static childContextTypes = { svgId: numberProp, isInGroup: PropTypes.bool, @@ -17,13 +22,16 @@ class G extends Component{ }; getChildContext = () => { - return _.reduce(contextProps, (props, value, key) => { - props[key] = this.props[key]; + let context = _.reduce(contextProps, (props, value, key) => { + if (!_.isNil(this.props[key])) { + props[key] = this.props[key]; + } return props; }, { - svgId: this.props.svgId, + svgId: this.props.svgId || this.context.svgId, isInGroup: true }); + return _.defaults({}, this.context, context); }; render() {