# elementor/3.8.0-beta1/app/modules/onboarding/assets/js/utils/connect.js

Elementor Website Builder – more than just a page builder, version 3.8.0-beta1. 41 lines.

- Page: https://pluginprobe.com/plugins/elementor/3.8.0-beta1/code/app/modules/onboarding/assets/js/utils/connect.js
- Raw: https://pluginprobe.com/plugins/elementor/3.8.0-beta1/raw/app/modules/onboarding/assets/js/utils/connect.js
- Modified: 2022-09-19T16:26:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/elementor/3.8.0-beta1/code/app/modules/onboarding/assets/js/utils/connect.js#L10-L20`.

```javascript
import { useEffect, useContext } from 'react';
import { OnboardingContext } from '../context/context';

export default function Connect( props ) {
	const { state, updateState, getStateObjectToUpdate } = useContext( OnboardingContext );

	const connectSuccessCallback = ( data ) => {
		const stateToUpdate = getStateObjectToUpdate( state, 'steps', 'account', 'completed' );

		elementorCommon.config.library_connect.is_connected = true;
		elementorCommon.config.library_connect.current_access_level = data.kits_access_level || data.access_level || 0;

		stateToUpdate.isLibraryConnected = true;

		updateState( stateToUpdate );
	};

	useEffect( () => {
		jQuery( props.buttonRef.current ).elementorConnect( {
			success: ( data ) => props.successCallback ? props.successCallback( data ) : connectSuccessCallback( data ),
			error: () => {
				if ( props.errorCallback ) {
					props.errorCallback();
				}
			},
			popup: {
				width: 726,
				height: 534,
			},
		} );
	}, [] );

	return null;
}

Connect.propTypes = {
	buttonRef: PropTypes.object.isRequired,
	successCallback: PropTypes.func,
	errorCallback: PropTypes.func,
};

```
