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
class Autocomplete extends React.Component { | |
constructor(props) { | |
super(props) | |
this.state = { | |
results: props.options | |
} | |
} | |
searchList(event) { |
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
class SearchSelect extends React.Component { | |
constructor(props) { | |
super(props) | |
this.state = { | |
results: props.options | |
} | |
} | |
searchList(event) { | |
const results = this.props.filterMethod(this.props.options, event.target.value) |
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
import SearchSelect from './search-select' | |
class Autocomplete extends React.Component { | |
constructor(props) { | |
super(props) | |
} | |
filterMethod (options, query) { | |
return options.filter(option => option.toLowerCase().includes(query.toLowerCase())) | |
} |
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
import SearchSelect from './search-select' | |
class TagListSearch extends React.Component { | |
constructor(props) { | |
super(props) | |
} | |
filterMethod (options, query) { | |
return options.filter(option => option.toLowerCase().includes(query.toLowerCase())) | |
} |
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
class App extends React.Component { | |
constructor(props) { | |
super(props) | |
} | |
render() { | |
return ( | |
<div className="wrapper"> | |
<ObserveDimensions | |
render={({width, height}) => ( |
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
class ObserveDimensions extends React.Component { | |
constructor(props) { | |
super(props) | |
this.state = { | |
width: null, | |
height: null | |
} | |
this.elementToObserve = React.createRef() | |
} |
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
class App extends React.Component { | |
constructor(props) { | |
super(props) | |
} | |
render() { | |
return ( | |
<div className="wrapper"> | |
<FetchData | |
url="https://jsonplaceholder.typicode.com/todos" |
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
class FetchData extends React.Component { | |
constructor(props) { | |
super(props) | |
this.state = { | |
loading: false, | |
results: [], | |
error: false | |
} | |
} |
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
Vue.component('search-select', { | |
props: [ | |
'options', | |
'filterMethod' | |
], | |
data () { | |
return { | |
query: '' | |
} |
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
Vue.component('autocomplete', { | |
data () { | |
return { | |
dropdownVisible: false | |
} | |
}, | |
methods: { | |
filterMethod (options, query) { | |
return options.filter(option => option.toLowerCase().includes(query.toLowerCase())) |
OlderNewer