Changeset View
Changeset View
Standalone View
Standalone View
native/account/registration/registration-context-provider.react.js
// @flow | // @flow | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import { RegistrationContext } from './registration-context.js'; | import { RegistrationContext } from './registration-context.js'; | ||||
import { useRegistrationServerCall } from './registration-server-call.js'; | |||||
type Props = { | type Props = { | ||||
+children: React.Node, | +children: React.Node, | ||||
}; | }; | ||||
function RegistrationContextProvider(props: Props): React.Node { | function RegistrationContextProvider(props: Props): React.Node { | ||||
const contextValue = React.useMemo(() => ({}), []); | const registrationServerCall = useRegistrationServerCall(); | ||||
const contextValue = React.useMemo( | |||||
() => ({ | |||||
register: registrationServerCall, | |||||
}), | |||||
[registrationServerCall], | |||||
); | |||||
return ( | return ( | ||||
<RegistrationContext.Provider value={contextValue}> | <RegistrationContext.Provider value={contextValue}> | ||||
{props.children} | {props.children} | ||||
</RegistrationContext.Provider> | </RegistrationContext.Provider> | ||||
); | ); | ||||
} | } | ||||
export { RegistrationContextProvider }; | export { RegistrationContextProvider }; |