-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(Ref): add a basic example (#2226)
- Loading branch information
1 parent
7bb5156
commit f555a97
Showing
4 changed files
with
75 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React, { Component } from 'react' | ||
import { Grid, Table, Ref, Segment } from 'semantic-ui-react' | ||
|
||
export default class RefExampleRef extends Component { | ||
state = {} | ||
|
||
handleRef = node => this.setState({ node }) | ||
|
||
render() { | ||
const { node } = this.state | ||
|
||
return ( | ||
<Grid columns={2}> | ||
<Grid.Column> | ||
<Ref innerRef={this.handleRef}> | ||
<Segment>An example node</Segment> | ||
</Ref> | ||
</Grid.Column> | ||
<Grid.Column> | ||
{node && ( | ||
<Table> | ||
<Table.Body> | ||
<Table.Row> | ||
<Table.Cell>nodeName</Table.Cell> | ||
<Table.Cell>{node.nodeName}</Table.Cell> | ||
</Table.Row> | ||
<Table.Row> | ||
<Table.Cell>nodeType</Table.Cell> | ||
<Table.Cell>{node.nodeType}</Table.Cell> | ||
</Table.Row> | ||
<Table.Row> | ||
<Table.Cell>textContent</Table.Cell> | ||
<Table.Cell>{node.textContent}</Table.Cell> | ||
</Table.Row> | ||
</Table.Body> | ||
</Table> | ||
)} | ||
</Grid.Column> | ||
</Grid> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react' | ||
|
||
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample' | ||
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection' | ||
|
||
const RefTypesExamples = () => ( | ||
<ExampleSection title='Types'> | ||
<ComponentExample | ||
title='Ref' | ||
description={( | ||
<span> | ||
A component exposes the <code>innerRef</code> prop that always returns the DOM node of both functional and | ||
class component children. | ||
</span> | ||
)} | ||
examplePath='addons/Ref/Types/RefExampleRef' | ||
/> | ||
</ExampleSection> | ||
) | ||
|
||
export default RefTypesExamples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react' | ||
import Types from './Types' | ||
|
||
const RefExamples = () => ( | ||
<div> | ||
<Types /> | ||
</div> | ||
) | ||
|
||
export default RefExamples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters