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

docs(ui-text-area,ui-tree-browser): functional examples are added to TextArea, TreeBrowser #1670

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
3 changes: 2 additions & 1 deletion packages/__docs__/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import React, { forwardRef, useContext, useEffect, useMemo, useState, useRef } from 'react'
import React, { forwardRef, useCallback, useContext, useEffect, useMemo, useState, useRef } from 'react'
import ReactDOM from 'react-dom'

import { LoremIpsum } from 'lorem-ipsum'
Expand Down Expand Up @@ -82,6 +82,7 @@ const globals = {
placeholderImage,
React,
ReactDOM,
useCallback,
useContext,
useEffect,
useMemo,
Expand Down
40 changes: 27 additions & 13 deletions packages/ui-text-area/src/TextArea/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,29 +81,43 @@ type: example

A 'controlled' TextArea:

```js
---
type: example
---
- ```js
class Example extends React.Component {
state = { description: 'Hello World' }

handleChange = (e) => this.setState({ description: e.target.value })

render() {
return (
<TextArea
label="Description"
value={this.state.description}
onChange={this.handleChange}
/>
)
}
}

render(<Example />)
```

class Example extends React.Component {
state = { description: 'Hello World' };
- ```js
const Example = () => {
const [description, setDescription] = useState('Hello World')

handleChange = (e) => this.setState({ description: e.target.value});
const handleChange = (e) => setDescription(e.target.value)

render () {
return (
<TextArea
label="Description"
value={this.state.description}
onChange={this.handleChange}
value={description}
onChange={handleChange}
/>
)
}
}

render(<Example/>)
```
render(<Example />)
```

### Guidelines

Expand Down
Loading
Loading