Skip to content

Commit

Permalink
Datasource refactored from recompose to hooks. (#106640)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
Kuznietsov and kibanamachine authored Jul 26, 2021
1 parent 293a6d6 commit 89b8dc6
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions x-pack/plugins/canvas/public/components/datasource/datasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,17 @@
* 2.0.
*/

import { compose, branch, renderComponent } from 'recompose';
import React from 'react';
import PropTypes from 'prop-types';
import { NoDatasource } from './no_datasource';
import { DatasourceComponent } from './datasource_component';

const branches = [
// rendered when there is no datasource in the expression
branch(
({ datasource, stateDatasource }) => !datasource || !stateDatasource,
renderComponent(NoDatasource)
),
];
export const Datasource = (props) => {
const { datasource, stateDatasource } = props;
if (!datasource || !stateDatasource) return <NoDatasource {...props} />;

export const Datasource = compose(...branches)(DatasourceComponent);
return <DatasourceComponent {...props} />;
};

Datasource.propTypes = {
args: PropTypes.object,
Expand Down

0 comments on commit 89b8dc6

Please sign in to comment.