Skip to content

Commit

Permalink
Add: className prop support to server side render.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Jan 29, 2019
1 parent 4a717ae commit c362d0b
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions packages/components/src/server-side-render/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,42 @@ export class ServerSideRender extends Component {

render() {
const response = this.state.response;
const { className } = this.props;
if ( ! response ) {
return (
<Placeholder><Spinner /></Placeholder>
<Placeholder
className={ className }
>
<Spinner />
</Placeholder>
);
} else if ( response.error ) {
// translators: %s: error message describing the problem
const errorMessage = sprintf( __( 'Error loading block: %s' ), response.errorMsg );
return (
<Placeholder>{ errorMessage }</Placeholder>
<Placeholder
className={ className }
>
{ errorMessage }
</Placeholder>
);
} else if ( ! response.length ) {
return (
<Placeholder>{ __( 'No results found.' ) }</Placeholder>
<Placeholder
className={ className }
>
{ __( 'No results found.' ) }
</Placeholder>
);
}

return (
<RawHTML key="html">{ response }</RawHTML>
<RawHTML
key="html"
className={ className }
>
{ response }
</RawHTML>
);
}
}
Expand Down

0 comments on commit c362d0b

Please sign in to comment.