openreplay/frontend/app/components/hocs/withEnumToggle.js
Shekar Siri 2ed5cac986
Webpack upgrade and dependency cleanup (#523)
* change(ui) - webpack update
* change(ui) - api optimize and other fixes
2022-06-03 16:47:38 +02:00

21 lines
519 B
JavaScript

import React from 'react';
const withEnumToggle = (stateName = 'active', handlerName = 'setActive', initial) => BaseComponent =>
class extends React.Component {
state = {
active: initial,
};
setActive = state => this.setState({
active: state,
})
render() {
const newProps = {
[ handlerName ]: this.setActive,
[ stateName ]: this.state.active,
};
return <BaseComponent { ...newProps } { ...this.props } />;
}
};
export default withEnumToggle;