Skip to content

Commit 8a52918

Browse files
committed
fix(aws-amplify-react): correctly hide links under production mode
1 parent a04f1cd commit 8a52918

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

packages/aws-amplify-react/src/Auth/Authenticator.jsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,13 @@ export default class Authenticator extends Component {
170170
<Loading/>
171171
];
172172

173-
const props_children_names = React.Children.map(props_children, child => child.type.name);
173+
// const props_children_names = React.Children.map(props_children, child => child.type.name);
174174
const props_children_override = React.Children.map(props_children, child => child.props.override);
175-
hide = hide.filter((component) =>!props_children_names.includes(component.name));
176-
const hideLink = hide.filter((component) => {
177-
return !props_children_override.some(comp => comp === component);
178-
});
175+
// hide = hide.filter((component) =>!props_children_names.includes(component.name));
176+
hide = hide.filter((component) => !props_children.find(child => child.type === component));
177+
// const hideLink = hide.filter((component) => {
178+
// return !props_children_override.some(comp => comp === component);
179+
// });
179180

180181
const render_props_children = React.Children.map(props_children, (child, index) => {
181182
return React.cloneElement(child, {
@@ -187,7 +188,7 @@ export default class Authenticator extends Component {
187188
onStateChange: this.handleStateChange,
188189
onAuthEvent: this.handleAuthEvent,
189190
hide,
190-
hideLink
191+
override: props_children_override
191192
});
192193
});
193194

@@ -201,7 +202,7 @@ export default class Authenticator extends Component {
201202
onStateChange: this.handleStateChange,
202203
onAuthEvent: this.handleAuthEvent,
203204
hide,
204-
hideLink
205+
override: props_children_override
205206
});
206207
});
207208

packages/aws-amplify-react/src/Auth/SignIn.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import Auth from '@aws-amplify/auth';
1717

1818
import AuthPiece from './AuthPiece';
1919
import { FederatedButtons } from './FederatedSignIn';
20+
import SignUp from './SignUp';
21+
import ForgotPassword from './ForgotPassword';
2022

2123
import {
2224
FormSection,
@@ -116,10 +118,10 @@ export default class SignIn extends AuthPiece {
116118
}
117119

118120
showComponent(theme) {
119-
const { authState, hide = [], federated, onStateChange, onAuthEvent, hideLink=[] } = this.props;
121+
const { authState, hide = [], federated, onStateChange, onAuthEvent, override=[] } = this.props;
120122
if (hide && hide.includes(SignIn)) { return null; }
121-
const hideSignUp = hideLink.some(component => component.name === 'SignUp');
122-
const hideForgotPassword =hideLink.some(component => component.name === 'ForgotPassword');
123+
const hideSignUp = !override.includes('SignUp') && hide.some(component => component === SignUp);
124+
const hideForgotPassword = !override.includes('ForgotPassword') && hide.some(component => component === ForgotPassword);
123125
return (
124126
<FormSection theme={theme}>
125127
<SectionHeader theme={theme}>{I18n.get('Sign in to your account')}</SectionHeader>

0 commit comments

Comments
 (0)