Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for anything renderable as children rather than just strings. #272

Merged
merged 1 commit into from
May 9, 2017

Conversation

kaseyjcowley
Copy link
Contributor

Hi all,

We recently upgraded to v5.0.3 and ran across the following error:
image

The error is due to only children of type string being supported rather than anything renderable. This PR contains a failing test with a example of using JS expressions within children.

From React docs https://facebook.github.io/react/docs/jsx-in-depth.html#children-in-jsx

In JSX expressions that contain both an opening tag and a closing tag, the content between those tags is passed as a special prop: props.children. There are several different ways to pass children [...]

Where children can typically be anything that can be rendered: numbers, strings, elements or an array (or fragment) containing these types (from PropTypes.children)

With the current API, I would expect children of these various types to be supported. However for example, <title> requires the children to be strings.

To summarize by examples:

const title = 'The Title';

// Works
<Helmet>
  <title>Title: The Title</title>
</Helmet>

// Works
<Helmet>
  <title>{'Title: The Title'}</title>
</Helmet>

// Works
<Helmet>
  <title>{'Title: ' + title}</title>
</Helmet>

// Doesn't Work
<Helmet>
  <title>Title: {title}</title>
</Helmet>

@CLAassistant
Copy link

CLAassistant commented Apr 26, 2017

CLA assistant check
All committers have signed the CLA.

@cwelch5
Copy link
Contributor

cwelch5 commented May 4, 2017

@kchunterdeluxe Could you sign the CLA please? So we can give you credit for the unit test. Thanks!

@kaseyjcowley
Copy link
Contributor Author

@cwelch5, CLA signed

@cwelch5 cwelch5 merged commit e23f4fb into nfl:master May 9, 2017
cwelch5 pushed a commit that referenced this pull request May 9, 2017
* fix: Add support for anything renderable as children rather than just strings.

Fixes #272
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants