sst.dev icon indicating copy to clipboard operation
sst.dev copied to clipboard

Comments: Render the Note Form

Open jayair opened this issue 9 years ago • 14 comments

Link to chapter - http://serverless-stack.com/chapters/render-the-note-form.html

jayair avatar Apr 10 '17 01:04 jayair

When I click a note to examine, the page redirects to prod/notes/undefined - and I get an error. Trying to figure out why the pushed link is undefined, instead of the dynamo db note id.

mikhael28 avatar Jul 26 '17 06:07 mikhael28

@mikhaelbendavid You can check what is being returned by adding a console.log here - https://github.com/AnomalyInnovations/serverless-stack-demo-client/blob/render-the-note-form/src/containers/Home.js#L31.

jayair avatar Jul 26 '17 17:07 jayair

When I click one of my note, a status code 500 returned.

RaphaelMui avatar Aug 09 '17 09:08 RaphaelMui

@RaphaelMui The 500 error should be something we are generating. Make sure the link for the note looks right. You can also check your CloudWatch logs for the error.

jayair avatar Aug 09 '17 17:08 jayair

@jayair The Request URL is https://uy6essyal3.execute-api.us-east-1.amazonaws.com/prod/notes/9704e3b0-7d82-11e7-9f52-abe788a40b9a

From the CloudWatch logs,

2017-08-10T08:13:34.778Z	cd8bc624-7da3-11e7-a4d5-bf4a01ad26b2	ReferenceError: error is not defined
at _callee$ (/var/task/get.js:199:27)
at tryCatch (/var/task/node_modules/regenerator-runtime/runtime.js:65:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/var/task/node_modules/regenerator-runtime/runtime.js:303:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/var/task/node_modules/regenerator-runtime/runtime.js:117:21)
at step (/var/task/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
at /var/task/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13
at process._tickDomainCallback (internal/process/next_tick.js:135:7)

RaphaelMui avatar Aug 10 '17 08:08 RaphaelMui

@RaphaelMui Hmm that seems a bit cryptic. Can you try adding some debug message? For example, you can add a console.log before this line - https://github.com/AnomalyInnovations/serverless-stack-demo-api/blob/master/get.js#L27

jayair avatar Aug 10 '17 23:08 jayair

I'm getting this error... ./src/containers/Notes Module build failed: Error: ENOENT: no such file or directory, open

inventanew avatar Dec 07 '17 19:12 inventanew

@inventanew Seems like that file might not be in the right location?

jayair avatar Dec 11 '17 11:12 jayair

With the demo app I am getting the following error "This XML file does not appear to have any style information associated with it. The document tree is shown below." Why is this happening? I am also seeing this with my local app. It seems like the URL may be miss formed.

mdhendri avatar Mar 22 '18 05:03 mdhendri

@mdhendri Which page of the demo app are you seeing this on - https://demo.serverless-stack.com?

jayair avatar Mar 22 '18 17:03 jayair

Yes, the issue was on https://demo.serverless-stack.com and also my own app. It seems that if there was an image in the S3 bucket prior to the switch to AWS Amplify somehow the URL got messed up and hence the error. If I uploaded another image then it seemed to resolve itself. The interesting thing is I tried it again this morning and I don't get that XML error.

On Thu, Mar 22, 2018 at 10:08 AM, Jay V [email protected] wrote:

@mdhendri https://github.com/mdhendri Which page of the demo app are you seeing this on - https://demo.serverless-stack.com?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AnomalyInnovations/serverless-stack-com/issues/54#issuecomment-375383851, or mute the thread https://github.com/notifications/unsubscribe-auth/AASDy0AIURhvFRknobnL-m7dcw-_dEqXks5tg9p-gaJpZM4M4OMo .

mdhendri avatar Mar 22 '18 17:03 mdhendri

How does wrapping JSX html code inside curly braces work? This line:

{this.state.note &&
        <form onSubmit={this.handleSubmit}>

Doesn't the && symbol make this a conditional statement? Wouldn't it just return a boolean? The instructions say "We render our form only when this.state.note is available." Is this the line that does that? How does && work here?

iggirex avatar Mar 30 '18 19:03 iggirex

@iggirex Yeah JSX is a bit confusing. One way to think about it is that React converts JSX into a set of standard JS calls to create components. In this case, if this.state.note is not null (or false), it'll return the React component called form. If it's null then it won't render anything.

Here is some info on how false is rendered in JSX - https://reactjs.org/docs/conditional-rendering.html#inline-if-with-logical--operator.

jayair avatar Mar 30 '18 22:03 jayair

This issue was moved to https://discourse.serverless-stack.com/t/comments-render-the-note-form/140

jayair avatar May 09 '18 20:05 jayair