Download react-color/src/helpers/interaction.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 496 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-color/src/helpers/interaction.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-color/src/helpers/interaction.js
-
curl -L -o interaction.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-color/src/helpers/interaction.js
496 Bytes
| /* eslint-disable no-invalid-this */ | |
| import React from 'react' | |
| export const handleFocus = (Component, Span = 'span') => | |
| class Focus extends React.Component { | |
| state = { focus: false } | |
| handleFocus = () => this.setState({ focus: true }) | |
| handleBlur = () => this.setState({ focus: false }) | |
| render() { | |
| return ( | |
| <Span onFocus={ this.handleFocus } onBlur={ this.handleBlur }> | |
| <Component { ...this.props } { ...this.state } /> | |
| </Span> | |
| ) | |
| } | |
| } | |