mirror of
https://github.com/jlengrand/adyen-web.git
synced 2026-03-10 08:01:22 +00:00
* feat: draft * feat: cleaned up * feat: converted some files to ts * fix: redirect result + typescript * feat: cleaned up server * feat: adding some stories * feat: more changes * feat: small adjustments * feat: removed docs. cleaned preview * feat: cleanup * feat: clean up types * feat: adding to window object * feat: global loaders * feat: added type to loaded checkout * feat: storybook 7 + vite * feat: cleanup deps not used by vite or storybook * feat: removing unused import * Update main.ts * feat: webpack5 * feat: attempt to update packages * refactor: move storybook to lib * refactor: use rollup.dev.config.js * refactor: redirect story fix and add a11y check * refactor: rename story * refactor: split rollup config * refactor(storybook-config): use dev rollup config * remove playground-storybook folder * some fix * run storybook https * rebase main resolve conflicts * add mirrored rollup dev plugins to vite * correct postcss.config.js path * fix returnUrl * refactor: remove unused code and add types * feat: cleaning up --------- Co-authored-by: Yu Long <longyu901009@gmail.com>
23 lines
727 B
TypeScript
23 lines
727 B
TypeScript
import { useEffect, useRef } from 'preact/hooks';
|
|
import Core from '../../src/core';
|
|
import { PaymentMethodOptions, PaymentMethods } from '../../src/types';
|
|
|
|
interface IContainer<T extends keyof PaymentMethods> {
|
|
type: T;
|
|
componentConfiguration: PaymentMethodOptions<T>;
|
|
checkout: Core;
|
|
}
|
|
|
|
export const Container = <T extends keyof PaymentMethods>({ type, componentConfiguration, checkout }: IContainer<T>) => {
|
|
const container = useRef(null);
|
|
|
|
useEffect(() => {
|
|
if (!checkout) {
|
|
return;
|
|
}
|
|
checkout.create(type, { ...componentConfiguration }).mount(container.current);
|
|
}, []);
|
|
|
|
return <div ref={container} id="component-root" className="component-wrapper" />;
|
|
};
|