question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Select.Async returns undefined

See original GitHub issue

Hi,

I’m writing about a curious case. (Just followed the given documentation). First off is it broken?

utils/requests/schools

import axios from 'axios'
import 'utils/interceptors'

export function search (id) {
  return (query) => {
    return axios.get(__API__ + '/division/' + id + '/school', {
      params: {
        query: query
      }
    })
    .then((response) => {
      return response.json()
    })
    .then((json) => {
      return {
        options: json
      }
    })
  }
}

react component

import React, { PropTypes } from 'react'

import Select from 'react-select'
import { search } from 'utils/requests/schools'

class MyExampleView extends React.Component {

  render () {
    return (
      <div className='panel'>
              <Select.Async
                loadOptions={search(this.props.params.id)}
                autoload={true} />

      </div>
    )
  }
}

It seems that Async is undefined.

I tried

import { Async } from 'react-select'
console.log(Async) //returned undefined

import Select from 'react-select'
console.log(Select.Async) //returned undefined  

Why do you think is that?

screen shot 2016-01-08 at 9 56 02 am

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9

github_iconTop GitHub Comments

5reactions
tomRedoxcommented, Feb 17, 2016

Possibly the issue here is that Select.Async only works with version 1.0.0 of react-select onwards. The documentation is now showing 1.0.0 syntax, but doing an npm install for react-select will currently get the 0.9.x version, so the docs are then wrong for that version.

I have just found this out the hard way!

2reactions
lightshirecommented, Jan 9, 2016

@aeleftheriadis fixed it with:

<Select
              asyncOptions={search(this.props.params.id)}
                onChange={::this.handleSelectChange}
                value={selected.label}
               />

note: i didn’t use Select.Async, i used Select

Read more comments on GitHub >

github_iconTop Results From Across the Web

JS async function returning undefined although calling it ...
log(userInfo) // It's result is undefined if (userInfo) { res.render('dashboard/profile', { fullName: userInfo.fname + " " + userInfo.
Read more >
Async/Await returning undefined : r/learnjavascript - Reddit
Hi, I'm just learning about async/await, and more generally, callbacks/promises. In the example below, erpBaseUrl within the newOrder ...
Read more >
async function expression - JavaScript - MDN Web Docs
An async function expression can be used as an IIFE (Immediately Invoked Function Expression) which runs as soon as it is defined. See...
Read more >
Async/Await Error Handling - Beginner JavaScript - Wes Bos
You often have a function with a few promises inside of it, but then you want to wait for that entire function to...
Read more >
Handling `undefined` in React Query and Typescript - neldeles
Generally, on the first render cycle, data will be undefined because well, the data is async and does not exist yet on the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found