Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update creating-dynamic-blocks.md #10786

Merged
merged 2 commits into from
Oct 24, 2018
Merged

Conversation

mrmadhat
Copy link
Contributor

Description

While posts are loading inside the edit method the posts variable is null, attempting to access post[0] causes an error

"TypeError: Cannot read property '0' of null" and the block displays "This block has encountered an error and cannot be previewed."

checking that posts has a value resolves this.

How has this been tested?

I have tested these changes in browser.

Types of changes

Bug fix in creating your first block docs

While posts are loading inside the edit method the `posts` variable is null, attempting to access `post[0]` causes an error 

"TypeError: Cannot read property '0' of null" and the block displays "This block has encountered an error and cannot be previewed." 

checking that posts has a value resolves this.
@Soean Soean added the [Type] Developer Documentation Documentation for developers label Oct 19, 2018
Copy link
Contributor

@chrisvanpatten chrisvanpatten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the docs contributions! 📖 💟

if ( ! props.posts ) {
return "Loading...";
}
if ( props.posts.length === 0 ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recognise that it doesn't really matter much but could we have a newline before this if block and after this if block? It makes it slightly easier to read.

Going to approve it though because it's a small thing and otherwise looks great to me!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @chrisvanpatten I've added the spacing to both this if and the one in your other comment 😃

docs/blocks/creating-dynamic-blocks.md Show resolved Hide resolved
@chrisvanpatten
Copy link
Contributor

Just for a sanity check I want @ajitbohra to take a look too ^__^

@ajitbohra
Copy link
Member

@mrmadhat thank you 👍

@ajitbohra ajitbohra merged commit b022ad2 into WordPress:master Oct 24, 2018
@youknowriad youknowriad added this to the 4.2 milestone Oct 24, 2018
antpb pushed a commit to antpb/gutenberg that referenced this pull request Oct 26, 2018
* Update creating-dynamic-blocks.md

While posts are loading inside the edit method the `posts` variable is null, attempting to access `post[0]` causes an error 

"TypeError: Cannot read property '0' of null" and the block displays "This block has encountered an error and cannot be previewed." 

checking that posts has a value resolves this.

* Added spacing to improve readability
@mrmadhat mrmadhat deleted the patch-1 branch October 26, 2018 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants