Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Add prototype for Custom Styled Toolbar @miroslavstastny ([#1541](https://github.com/stardust-ui/react/pull/1541))
- Add Best Practices section for each component @alinais ([#1550](https://github.com/stardust-ui/react/pull/1550))
- Update `Layout` guide @layershifter ([#1595](https://github.com/stardust-ui/react/pull/1595))
- Fix error when children are missing in `ExampleSnippet` @layershifter ([#1619](https://github.com/stardust-ui/react/pull/1619))

<!--------------------------------[ v0.34.0 ]------------------------------- -->
## [v0.34.0](https://github.com/stardust-ui/react/tree/v0.34.0) (2019-06-26)
Expand Down
7 changes: 5 additions & 2 deletions docs/src/components/ExampleSnippet/ExampleSnippet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import * as React from 'react'
import renderElementToJSX from './renderElementToJSX'

export type ExampleSnippetProps = {
render?: () => React.ReactNode
children?: React.ReactElement
render?: () => React.ReactElement
value?: string
}

Expand All @@ -21,7 +22,9 @@ const renderedStyle = {
const ExampleSnippet: React.FunctionComponent<ExampleSnippetProps> = props => {
const { children, render = () => null, value } = props

const element: React.ReactNode = render() || React.Children.only(children)
const child: React.ReactElement | null = render() || children
const element: React.ReactElement = child ? React.Children.only(child) : null

const isFunctionWithoutValue = render && !value
const string = value || renderElementToJSX(element, !isFunctionWithoutValue)

Expand Down