How to use the recompose.lifecycle function in recompose

To help you get started, we’ve selected a few recompose examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github geosolutions-it / MapStore2 / web / client / plugins / FeatureEditor.jsx View on Github external
const EditorPlugin = compose(
    connect(selector,
        (dispatch) => ({
            onMount: bindActionCreators(setUp, dispatch),
            gridEvents: bindActionCreators(gridEvents, dispatch),
            pageEvents: bindActionCreators(pageEvents, dispatch),
            initPlugin: bindActionCreators((options) => initPlugin(options), dispatch),
            toolbarEvents: bindActionCreators(toolbarEvents, dispatch),
            gridTools: gridTools.map((t) => ({
                ...t,
                events: bindActionCreators(t.events, dispatch)
            })),
            onSizeChange: (...params) => dispatch(sizeChange(...params))
        })
    ),
    lifecycle({
        componentDidMount() {
            // only the passed properties will be picked
            this.props.onMount(pick(this.props, ['showFilteredObject', 'showTimeSync', 'timeSync']));
        }
    })
)(FeatureDock);


module.exports = {
    FeatureEditorPlugin: EditorPlugin,
    epics: require('../epics/featuregrid'),
    reducers: {
        featuregrid: require('../reducers/featuregrid')
    }
};
github geosolutions-it / MapStore2 / web / client / components / TOC / enhancers / tocItemsSettings.js View on Github external
onHideSettings();
                onShowAlertModal(false);
                // clean up internal settings state
                onUpdateOriginalSettings({});
                onUpdateInitialSettings({});
            }
        },
        onSave: ({ onUpdateInitialSettings = () => {}, onUpdateOriginalSettings = () => {}, onHideSettings = () => { }, onShowAlertModal = () => { } }) => () => {
            onHideSettings();
            onShowAlertModal(false);
            // clean up internal settings state
            onUpdateOriginalSettings({});
            onUpdateInitialSettings({});
        }
    }),
    lifecycle({
        componentWillMount() {
            const {
                element = {},
                onUpdateOriginalSettings = () => { },
                onUpdateInitialSettings = () => { }
            } = this.props;

            // store changed keys
            onUpdateOriginalSettings({ ...element });
            // store initial settings (internal state)
            onUpdateInitialSettings({ ...element });
        },
        componentWillReceiveProps(newProps) {
            // an empty description does not trigger the single layer getCapabilites,
            // it does only for missing description
            const {
github nick121212 / fx-schema-form / packages / fx-schema-form-antd / out / app.js View on Github external
___scope___.file("components/formitem/hocs/temp.jsx", function(exports, require, module, __filename, __dirname){
var __decorate = __fsbx_decorate(arguments)
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = require("react");
const recompose_1 = require("recompose");
const pick_1 = require("recompose/utils/pick");
const metaConnect = recompose_1.compose(recompose_1.lifecycle({
    shouldComponentUpdate: function (nextProps, nextState) {
        console.group(nextProps.mergeSchema.keys + "---temp中比较formItemData和Meta的值得变化");
        console.log("formItemData", pick_1.default(nextProps, ["formItemData"]).formItemData, pick_1.default(this.props, ["formItemData"]).formItemData);
        console.log("meta", pick_1.default(nextProps, ["meta"]), pick_1.default(this.props, ["meta"]));
        let rtn = !recompose_1.shallowEqual(pick_1.default(nextProps, ["formItemData"]).formItemData, pick_1.default(this.props, ["formItemData"]).formItemData) ||
            !recompose_1.shallowEqual(pick_1.default(nextProps, ["meta"]).meta, pick_1.default(this.props, ["meta"]).meta);
        console.log("shouldUpdate", rtn);
        console.groupEnd();
        return rtn;
    }
}));
/**
 * 包装Template的组件HOC
 * @param Component 需要包装的组件
 * @param options   参数
 */
github gchq / stroom / stroom-ui / src / components / XsltEditor / XsltEditor.js View on Github external
const { xsltUpdated } = actionCreators;

const enhance = compose(
  withRouter,
  withHandlers({
    openDocRef: ({ history }) => d => history.push(`/s/doc/${d.type}/${d.uuid}`)
  }),
  connect(
    ({ xslt }, { xsltId }) => ({
      xslt: xslt[xsltId],
    }),
    {
      fetchXslt, xsltUpdated, saveXslt,
    },
  ),
  lifecycle({
    componentDidMount() {
      const { fetchXslt, xsltId } = this.props;

      fetchXslt(xsltId);
    },
  }),
  branch(({ xslt }) => !xslt, renderComponent(() => )),
);

const XsltEditor = ({
  xsltId, xslt, xsltUpdated, saveXslt, openDocRef, history,
}) => (
    
      
        
          <header></header>
github webex / react-widgets / packages / node_modules / @ciscospark / widget-message / src / enhancers / setup.js View on Github external
&& !sparkState.hasError
  ) {
    getFeatures(props);
  }
}

export default compose(
  connect(
    getMessageWidgetProps,
    (dispatch) => bindActionCreators({
      connectToMercury,
      getFeature,
      updateWidgetState
    }, dispatch)
  ),
  lifecycle({
    componentWillMount() {
      setup(this.props);
    },
    shouldComponentUpdate(nextProps) {
      return nextProps !== this.props;
    },
    componentWillReceiveProps(nextProps) {
      setup(nextProps, this.props);
    }
  })
);
github cennznet / runanode / app / renderer / pages / exitingPage / container.js View on Github external
import { connect } from 'react-redux';
import { compose, lifecycle, withState } from 'recompose';

const mapStateToProps = ({nodeStateStore}) => ({
  nodeStateStore
});

const mapDispatchToProps = dispatch => ({
});

const enhance = lifecycle({

  componentDidMount() {
  },

  componentDidUpdate() {
  },
});

export default compose(
  connect(
    mapStateToProps,
    mapDispatchToProps
  ),
  enhance
);
github EdwaRen / Recycle-Can-Website / src / Components / Paint.jsx View on Github external
const {
  withScriptjs,
  withGoogleMap,
  GoogleMap,
  FusionTablesLayer,
} = require("react-google-maps");
const { SearchBox } = require("react-google-maps/lib/components/places/SearchBox");

const MapWithAFusionTablesLayer = compose(
  withProps({
    googleMapURL: "https://maps.googleapis.com/maps/api/js?key=AIzaSyBipGTaEpZxIOqSRoYJakq64x9BQNjZwJs&amp;v=3.exp&amp;libraries=geometry,drawing,places",
    loadingElement: <div style="{{">,
    containerElement: <div style="{{">,
    mapElement: <div style="{{">,
  }),
  lifecycle({
    componentWillMount() {
      const refs = {}

      this.setState({
        bounds: null,
        center: {
          lat: 45.4235937, lng: -75.7031177
        },
        markers: [],
        onMapMounted: ref =&gt; {
          refs.map = ref;
        },
        onBoundsChanged: () =&gt; {
          this.setState({
            bounds: refs.map.getBounds(),
            center: refs.map.getCenter(),</div></div></div>
github punksta / Cat-or-dog / src / containers / SettingsContainer.js View on Github external
const hoc = compose(
	connect(
		state => {
			return {isMusicEnabled: state.settings.isMusicEnabled};
		},
		dispatch => {
			return {
				setMusicEnabled: isEnabled => {
					dispatch({
						type: isEnabled ? "ENABLE_MUSIC" : "DISABLE_MUSIC"
					});
				}
			};
		}
	),
	lifecycle({
		async componentWillMount() {
			try {
				const crashEnabled = await isCrashEnabled();
				const eventsEnabled = await isEventsEnabled();
				this.setState({
					isEventsEnabled: eventsEnabled,
					isCrashReportsEnabled: crashEnabled
				});
			} catch (e) {
				this.setState({
					isEventsEnabled: false,
					isCrashReportsEnabled: false
				});
			}
		}
	}),
github NCI-GDC / portal-ui / app / react-components / components / SurvivalPlotWrapper.js View on Github external
onDomainChange: setXDomain,
      margins: {
        top: 15,
        right: 20,
        bottom: 40,
        left: 50,
      },
    });
  }
}

const enhance = compose(
  withState('xDomain', 'setXDomain', undefined),
  withState('survivalContainer', 'setSurvivalContainer', null),

  lifecycle({
    shouldComponentUpdate(nextProps, nextState) {
      return !_.isEqual(this.props, nextProps) || !_.isEqual(this.state, nextState);
    },

    componentDidUpdate() {
      renderSurvivalPlot(this.props);
    },

    componentDidMount() {
      renderSurvivalPlot(this.props);
    },
  })
);

export default enhance(SurvivalPlotWrapper);