Skip to content

Need a way to prevent component render on client side initial load #8017

@scsherwood

Description

@scsherwood

For Ad performance in an isomorphic application we need React to avoid rendering an Ad Component containing an ad position div on the client initial load. Here is the following scenario:

  1. React renders the ad position div on the server and sends html to client. This div is an empty div with an id attribute identifying the location to place an ad.
  2. Google gpt makes a request for ad before React lifecycle is finished on client, and the ad position div gets filled with an ad.
  3. React finds a mismatch with server and client ad position div, so it re-renders the empty ad position div on client wiping out the ad.

If there is a way to conditionally stop React from rendering the ad position div on the client, we have not found it.

Seems like there needs to be a flag or method in the react lifecycle that can be used to prevent a component render on certain conditions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions