eightshift-frontend-libs icon indicating copy to clipboard operation
eightshift-frontend-libs copied to clipboard

SSR blocks crash when using @wordpress/server-side-render

Open mbmjertan opened this issue 2 years ago • 0 comments

Describe your bug

This happens when using @wordpress/server-side-render in Eightshift Frontend Libs blocks (code example provided below):

Screenshot 2022-05-12 at 10 05 06

Notice how there are attributes in the request that weren't part of the attributes object of the component.

Screenshot 2022-05-12 at 10 04 52

This causes an error because of blockTopLevelId - removing it from the request makes it go through, but there are still a lot of attributes in the request.

Screenshot 2022-05-12 at 10 05 22

The error causes the block to crash.

This doesn't occur when using the Eightshift Frontend Libs-provided Server Side Render component, and the request doesn't include attributes we haven't explicitly added to the attributes object this time around:

Screenshot 2022-05-12 at 10 10 19

Steps to Reproduce

Failing JSX snippet when using WP Server Side Render, assuming authorMetaDateColor and authorMetaAuthorColor are valid attributes that are defined in the block manifest:

	<ServerSideRender
		block={blockFullName}
		attributes={{
			authorMetaDateColor,
			authorMetaAuthorColor,
			wrapperUse: false,
			authorMetaServerSideRender: true,
		}}
		urlQueryArgs={{ cacheBusting: JSON.stringify(attributes) }}
	/>

The same snipped works using the EFL SSR component.

Expected behavior

The WP Server Side Render component should not crash.

Screenshots, screen recording, code snippet

See above.

Environment info

PHP 7.4.29 on Valet nginx, macOS 12.3, WP 5.9.3

Please confirm that you have searched existing issues in this repo.

Yes

Please confirm that you have searched in our documentation and couldn't find the answer.

Yes

Please confirm that your bug occurs with all plugins uninstalled and with the default WordPress theme active.

No

mbmjertan avatar May 12 '22 08:05 mbmjertan