Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

0.12.2

Compare
Choose a tag to compare
@MoOx MoOx released this 20 May 21:16
· 1384 commits to master since this release
  • 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)