github MoOx/phenomic 0.12.2

latest releases: v1.0.0, v1.0.0-beta.11, v1.0.0-beta.10...
7 years ago
  • Added: BodyContainer component.
    This component is now recommended to used wrap pages body, in replacement of
    previous usage of dangerouslySetInnerHTML.
    Previous method still works but have
    a known issue.

    To use this component, you can simply replace in your layouts the following
    code

    {
      body &&
      <div
        dangerouslySetInnerHTML={ { __html: html } }
      />
    }

    By the following code

    <BodyContainer>{ body }</BodyContainer>

    Note that you will need to import BodyContainer like this

    import { BodyContainer } from "phenomic"

    Example of full diff

    import Helmet from "react-helmet"
    import invariant from "invariant"
    -import { joinUri } from "phenomic"
    +import { BodyContainer, joinUri } from "phenomic"
    
    class Page extends Component {
    
    //...
    
            {
              head.title &&
              <h1>{ head.title }</h1>
            }
            { header }
    -        {
    -          body &&
    -          <div
    -            dangerouslySetInnerHTML={ { __html: html } }
    -          />
    -        }
    +        <BodyContainer>{ body }</BodyContainer>
            { props.children }
            { footer }

    (#469)

Don't miss a new phenomic release

NewReleases is sending notifications on new releases.