Skip to content

Commit 9dee681

Browse files
committed
Preserve props passed to container when converting to dynamic
1 parent 585c390 commit 9dee681

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/plugins/rehype-static-to-dynamic.mjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,16 @@ function convertStaticToDynamic(code) {
161161
path.node.children.length === 0 &&
162162
navigatorInfo
163163
) {
164+
// Preserve any props passed to Navigation
165+
const navigationProps = path.node.openingElement.attributes || [];
166+
164167
// Replace with <NavigationContainer><MyStack /></NavigationContainer>
168+
// Pass the props from Navigation to NavigationContainer
165169
const newElement = t.jsxElement(
166-
t.jsxOpeningElement(t.jsxIdentifier('NavigationContainer'), []),
170+
t.jsxOpeningElement(
171+
t.jsxIdentifier('NavigationContainer'),
172+
navigationProps
173+
),
167174
t.jsxClosingElement(t.jsxIdentifier('NavigationContainer')),
168175
[
169176
t.jsxText('\n '),

0 commit comments

Comments
 (0)