Forum Replies Created
-
AuthorPosts
-
Zac Gordon
KeymasterThat is correct! isSelected is no longer needed for toolbars or inspector controls 🙂
I will add some notes to the course pages about this next week. Great catch!
Zac Gordon
KeymasterSometimes how it goes 🙂 please post up if you have troubles again!
Zac Gordon
KeymasterThat is correct! It may still be backwards compatible for a time but that is correct moving forward 🙂
I will add some notes to the videos next week 🙂
Zac Gordon
KeymasterNice! Thanks for posting updates about this! Hope you can get it easily working now ::
April 20, 2018 at 5:43 pm in reply to: CSS Pseudo-classes and dynamically generated style attributes #45525Zac Gordon
KeymasterI would check out the 1st and 2nd suggestions here for a discussion on this… like I said, not really a nice elegant solution unfortunately (that I’ve seen)
https://stackoverflow.com/questions/28365233/inline-css-styles-in-react-how-to-implement-ahover
April 20, 2018 at 12:53 pm in reply to: CSS Pseudo-classes and dynamically generated style attributes #45500Zac Gordon
KeymasterWhat’s the specific use case you’re trying to do? There may be another appropriate works around native JS limitations on adding pseudo classes on the fly.
Zac Gordon
KeymasterSorry about that. That was not correct, you can remove that.
Hmm, not seeing what the problem is. My suggestion is start with the working block example again and work through the steps of converting to your own block to see where it went wrong.
Zac Gordon
KeymasterI believe these docs are outdated.
The approach of registering the block on the server side is still being evolved, so I think it’s better and more flexible (and following existing WP conventions) to use
enqueue_block_editor_assets
andenqueue_block_assets
but both approaches should still work I believe.Zac Gordon
KeymasterYou have to enable rest api for your custom post type. This has to go somewhere in your code:
register_meta( 'post', 'subheading', [ 'show_in_rest' => true, ] );
That should be it
Zac Gordon
KeymasterOkay so like it says you can’t do this:
<div>1</div> <div>2</div>
And have to have a single element returned like this:
<div> <div>1</div> <div>2</div> </div>
I think I see an example of this in your save method. There might be another instance but that is the situation you are looking for 🙂
Hope that helps!
Zac Gordon
KeymasterHi Ebonie! Thank you for this suggestion!!! I have plans to do both of these hopefully once the course has become finalized. With having to do multiple revisions of the course and the cost of transcripts I unfortunately haven’t been able to do yet, but totally plan and hope to! Thank you for the spot on suggestion!!!
Zac Gordon
KeymasterOkay, so this line here is actually taking props and destructuring it.
} )( ( { attributes, posts, className, isSelected, setAttributes, RadioControl } ) => {
You could instead just let props be passed down instead of destructuring it here and update your other code to props.posts etc or you can just pass down the specific things you need into the inspector rather than passing all of props.
The other thing to mention here is that if changes in the inspector settings change the API request it will redraw the entire block and inspector, which is annoying.
If you look at the core latest posts block you’ll see its much more complex. I have talked with a core dev about how to improve this and will likely have an example not using withAPIData and rather making the API call using some other options they are working on adding. This isn’t ready quite yet, but you can look at this example from V1 of the course for an alternative approach to withAPIData:
https://github.com/zgordon/gutenberg-course/tree/v1/jsforwp-blocks/blocks/examples/13-dynamic-alt
Hope that helps!
Zac Gordon
KeymasterYup! Checkout that link on JSX conditionals for how to code without an else statement.
Looks something like this (untested but something like this)
{ !isEmpty && ( <a href={ url }> { text } </a> ) }
Hope that helps!!!
Zac Gordon
KeymasterCool. If you set a default value for that attribute to be an empty string it should solve that problem 🙂
Zac Gordon
KeymasterCheck the console log for the specific error
Zac Gordon
KeymasterOkay, I added an example block example to the repo called “11-url-input-conditional” that should give you a head start.
Might also want to explore this page a little bit on conditional logic in JSX 🙂
https://reactjs.org/docs/conditional-rendering.html
Hope that helps!
Zac Gordon
KeymasterTry taking a look at the URL Input example as a possible guide? You can see if that type of conditional statement could also be used in the save function.
Zac Gordon
KeymasterNice! Most likely using the style attribute on an element 👍
Zac Gordon
KeymasterHi Steve!
Just posted a patch that should resolve the issue. Looks like was just missing destructuring isSelected. Please let me know how it goes for you now.
You may also want to update to Gutenberg 2.6.0 👍
Thanks for this catch! Let me know if you have any issues still.
Zac Gordon
KeymasterOkay, I was totally looking in the wrong place. I believe the error came from an issue with some wp.date library stuff I was playing with and broke with 2.6.
I am *hoping* that everything works properly for you now!
Zac Gordon
KeymasterHey David,
Do you mind trying to format this code a bit so can help you try to spot the error? Can put in a code block or use single backtick before and after 🙂
Code
I don’t know if I cover Fragments in this course. I do cover them in my JS course.
Let’s get this formated or put in a gist and we’ll get fixed.
Zac Gordon
KeymasterYup!
I will keep everything up to date and will likely add a few more examples.
If there is anything specific you’d like to see please post it up to the Content Request thread 🙂
Yeah I think a lot of people will continue to take the ACF approach over GB for some content, especially for existing sites
April 9, 2018 at 10:50 am in reply to: InspectorControls – "The editor has encountered an unexpected error" #44712Zac Gordon
KeymasterHey folks! This is a delayed update but all these code samples should be fixed now!
April 9, 2018 at 10:49 am in reply to: Error with backgroundImage as attribute – can anyone help? #44710Zac Gordon
KeymasterNice! Good catch 🙂
Zac Gordon
KeymasterHey there!
At this time the videos are only available streaming on the site. Sorry for the inconvenience!
-
AuthorPosts