Closed aldegoeij closed 5 years ago
If I add:
import Amplify from "aws-amplify"
import awsconfig from "./../aws-exports"
import { withAuthenticator } from "aws-amplify-react"
Amplify.configure(awsconfig)
Without any actual use, the build-html
step of Gatsby crashes with a very weird error:
Error: /Users/alexander/Projects/bodycode/www/public/render-page.js:74355
{}.DEBUG = namespaces;
^
SyntaxError: Unexpected token .
Referring to render-page.js
snippet:
/**
* Save `namespaces`.
*
* @param {String} namespaces
* @api private
*/
function save(namespaces) {
if (null == namespaces) {
// If you set a process.env field to null or undefined, it gets cast to the
// string 'null' or 'undefined'. Just delete instead.
delete {}.DEBUG;
} else {
{}.DEBUG = namespaces;
}
}
Is there some kind of expected environment variable that is missing that is causing this? I have no idea how to go about debugging this...
the bug I'm talking about here is worked-around using https://github.com/escaladesports/gatsby-plugin-prefetch-google-fonts/issues/18 and actually related to debug
library used as dependency of gatsby.
So you can close the error part of this issue.
Still wondering why you didn't use the HOC though 😄
Hey, thanks for the issue! I'm not using withAuthenticator
because many people want to have custom control over their auth, so I created this project. I would also suggest using withAuthenticator if it suits your needs though.
Also, I've updated the dependencies and upgraded the Gatsby project, this should work now. @aldegoeij
how would you access the users data after withAuthenticator() has been called and the Auth.currentAuthenticatedUser() has been called. lets say i was using withAuthenticator() to protect a profile page ... as soon as the user is authenticated the profile page will be accessible but the data from that user data is not able to be accessed before that profile page is displayed.
The example for React / React Native is very simple using a HOC, but this repo has a more complex setup for Auth, why is that?
See: https://aws-amplify.github.io/docs/js/react#add-auth
Thanks!