Skip to content

Commit 82b944e

Browse files
committed
Fix #96
1 parent f4dfcdc commit 82b944e

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

src/index.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
isClassDeclaration,
1313
isExportDefaultDeclaration,
1414
isFunctionDeclaration,
15-
isFunctionExpression,
1615
isIdentifier,
1716
isVariableDeclaration,
1817
stringLiteral,
@@ -119,14 +118,6 @@ function wrapExportDefaultDeclaration(path: NodePath<any>) {
119118

120119
const { node } = path;
121120

122-
if (isIdentifier(node.declaration)) {
123-
node.declaration = wrapInHOC(node.declaration);
124-
}
125-
126-
if (isFunctionExpression(node.declaration)) {
127-
node.declaration = wrapInHOC(node.declaration);
128-
}
129-
130121
if (
131122
isFunctionDeclaration(node.declaration) ||
132123
isClassDeclaration(node.declaration)
@@ -145,6 +136,8 @@ function wrapExportDefaultDeclaration(path: NodePath<any>) {
145136
);
146137
}
147138
}
139+
} else {
140+
node.declaration = wrapInHOC(node.declaration);
148141
}
149142
}
150143

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export const getServerSideProps = withAuthUserTokenSSR({
2+
whenUnauthed: AuthAction.REDIRECT_TO_LOGIN,
3+
})(async ({ AuthUser }) => {
4+
// ...
5+
return {
6+
props,
7+
};
8+
});
9+
10+
export default withAuthUser()(Component);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { withSuperJSONPage as _withSuperJSONPage } from 'babel-plugin-superjson-next/tools';
2+
import { withSuperJSONProps as _withSuperJSONProps } from 'babel-plugin-superjson-next/tools';
3+
export const getServerSideProps = _withSuperJSONProps(
4+
withAuthUserTokenSSR({
5+
whenUnauthed: AuthAction.REDIRECT_TO_LOGIN,
6+
})(async ({ AuthUser }) => {
7+
// ...
8+
return {
9+
props,
10+
};
11+
}),
12+
['smth']
13+
);
14+
export default _withSuperJSONPage(withAuthUser()(Component));

0 commit comments

Comments
 (0)