Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- import Select from 'react-select';
- // http://127.0.0.1:8001/api/categories?project_id=1
- export default class CategoryList extends React.Component {
- constructor(props) {
- super(props);
- //this.onChange = this.onChange.bind(this);
- }
- onChange(value) {
- console.log(value);
- //this.setState(state);
- this.setState({
- value: value,
- });
- }
- getOptions(input) {
- return fetch(`/api/categories?project_id=1&${input}.json`)
- .then((response) => {
- return response.json();
- }).then((json) => {
- return { options: json };
- });
- }
- render() {
- return (
- <Select.Async
- name="form-field-name"
- value="3"
- onChange={ this.onChange }
- loadOptions={this.getOptions}
- />
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement