@brightlayer-ui/react-auth-workflow
Version:
Re-usable workflow components for Authentication and Registration within Eaton applications.
27 lines (26 loc) • 1.17 kB
JavaScript
/**
* @packageDocumentation
* @module RegistrationWorkflowContextProvider
*/
import React, { useMemo } from 'react';
import { RegistrationWorkflowContext } from './context.js';
export const RegistrationWorkflowContextProvider = (props) => {
// Extract the needed properties out
// Context value will not change unless a sub function is changed
// NOTE: When adding new props to RegistrationWorkflowContextProps be sure
// to also add them here so the parameters are copied.
const { currentScreen, totalScreens, nextScreen, previousScreen, screenData, updateScreenData, isInviteRegistration, } = props;
const memoizedProps = useMemo(() => {
const propsForContext = {
currentScreen,
totalScreens,
nextScreen,
previousScreen,
screenData,
updateScreenData,
isInviteRegistration,
};
return propsForContext;
}, [currentScreen, totalScreens, nextScreen, previousScreen, screenData, updateScreenData, isInviteRegistration]);
return (React.createElement(RegistrationWorkflowContext.Provider, { value: memoizedProps }, props.children));
};