Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Not playing nice with other plugins #86

Open
rolurq opened this issue Dec 6, 2018 · 0 comments
Open

Not playing nice with other plugins #86

rolurq opened this issue Dec 6, 2018 · 0 comments

Comments

@rolurq
Copy link

rolurq commented Dec 6, 2018

This plugin decorates the Hyper component, however, it takes from the props the customChildren and adds its components but then puts them in the customInnerChildren prop, here:

render() {
    const { customChildren } = this.props
    const existingChildren = customChildren ? customChildren instanceof Array ? customChildren : [customChildren] : [];

    return (
        React.createElement(Hyper, Object.assign({}, this.props, {
            customInnerChildren: existingChildren.concat(React.createElement('footer', { className: 'footer_footer' },
                React.createElement('div', { className: 'footer_group group_overflow' },
                    React.createElement('div', { className: 'component_component component_cwd' },
                        React.createElement('div', { className: 'component_item item_icon item_cwd item_clickable', title: this.state.cwd, onClick: this.handleCwdClick, hidden: !this.state.cwd }, this.state.cwd ? tildify(String(this.state.cwd)) : '')
                    )
                ),
                React.createElement('div', { className: 'footer_group' },
                    React.createElement('div', { className: 'component_component component_git' },
                        React.createElement('div', { className: `component_item item_icon item_branch ${this.state.remote ? 'item_clickable' : ''}`, title: this.state.remote, onClick: this.handleBranchClick, hidden: !this.state.branch }, this.state.branch),
                        React.createElement('div', { className: 'component_item item_icon item_number item_dirty', title: `${this.state.dirty} dirty ${this.state.dirty > 1 ? 'files' : 'file'}`, hidden: !this.state.dirty }, this.state.dirty),
                        React.createElement('div', { className: 'component_item item_icon item_number item_ahead', title: `${this.state.ahead} ${this.state.ahead > 1 ? 'commits' : 'commit'} ahead`, hidden: !this.state.ahead }, this.state.ahead)
                    )
                )
            ))
        }))
    );
}

The problem with this, is that if other plugin decorates this component, if it uses customInnerChildren the elements it puts there will be ignored, because this plugin overwrites completely that property; and if it uses customChildren, the components the other plugin puts there will be rendered twice, because this plugin takes that property and joins them in the customInnerChildren.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant