Skip to content

Commit 40ae9b0

Browse files
Set the width of the wrapper div to 100% to preserve the "full width" expectation of embedded components (#86) (#87)
1 parent bdbd79a commit 40ae9b0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/useCreateComponent.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@ export const useCreateComponent = <T extends ConnectElementTagName>(
1414
>(null);
1515
const {connectInstance} = useConnectComponents();
1616
const wrapperDivRef = React.useRef<HTMLDivElement | null>(null);
17-
const wrapper = <div ref={wrapperDivRef}></div>;
17+
18+
// We set width to 100% to preserve this functionality aspect of embedded components even though
19+
// we are introducing a wrapper div for this element
20+
// https://docs.corp.stripe.com/connect/get-started-connect-embedded-components#width-and-height
21+
const wrapper = <div style={{width: '100%'}} ref={wrapperDivRef}></div>;
1822

1923
React.useLayoutEffect(() => {
2024
if (wrapperDivRef.current !== null && component === null) {
2125
const newComponent = connectInstance.create(tagName);
26+
2227
setComponent(newComponent);
2328
if (newComponent !== null) {
2429
try {

0 commit comments

Comments
 (0)