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

async typeahead crashes when typing after overrideOptions is set to true #137

Open
ivarprudnikov opened this issue Nov 19, 2019 · 0 comments

Comments

@ivarprudnikov
Copy link

ivarprudnikov commented Nov 19, 2019

The issue

What happens? -> React app crashes when user is typing into asyncTypeahead field with an option overrideOptions is set to true

Expected behavior: there should be no crash.

Example reproducing an issue: An example on codesandbox:
Edit dreamy-williams-6yple

Example details

Otherwise this is what I used to reproduce:
package.json

{
  "dependencies": {
    "react": "16.10.2",
    "react-dom": "16.10.2",
    "react-bootstrap-typeahead": "3.1.4",
    "react-jsonschema-form": "1.8.0",
    "react-jsonschema-form-extras": "0.9.48",
    "react-scripts": "3.2.0"
  },
  "scripts": {
    "start": "react-scripts start"
  }
}
// React app
import React from "react";
import { render } from "react-dom";
import Form from "react-jsonschema-form";
import { AsyncTypeaheadField } from "react-jsonschema-form-extras/lib/TypeaheadField";

let schema = {
  type: "object",
  properties: {
    user: { type: "string" }
  }
};

const uiSchema = {
  user: {
    "ui:field": "asyncTypeahead",
    asyncTypeahead: {
      url: "https://jsonplaceholder.typicode.com/users",
      minLength: 1,
      labelKey: "username",
      overrideOptions: true
    }
  }
};

const App = () => (
  <Form
    schema={schema}
    uiSchema={uiSchema}
    fields={{ asyncTypeahead: AsyncTypeaheadField }}
    onChange={data => console.log("changed", data)}
    onSubmit={data => console.log("submitted", data)}
    onError={err => console.log("errors", err)}
  />
);

render(<App />, document.getElementById("root"));

Skipping index.html file here for brevity.

Crash details

After typing into the search box the app will crash with an error:

The above error occurred in the <TypeaheadContainer(WrappedTypeahead)> component:
    in TypeaheadContainer(WrappedTypeahead) (created by OnClickOutside(TypeaheadContainer(WrappedTypeahead)))
    in OnClickOutside(TypeaheadContainer(WrappedTypeahead)) (created by AsyncContainer(OnClickOutside(TypeaheadContainer(WrappedTypeahead))))
    in AsyncContainer(OnClickOutside(TypeaheadContainer(WrappedTypeahead))) (created by AsyncTypeaheadField)
    in div (created by AsyncTypeaheadField)
    in AsyncTypeaheadField (created by SchemaField
    in div (created by WrapIfAdditional)
    in WrapIfAdditional (created by DefaultTemplate)
    in DefaultTemplate (created by SchemaField)
    in SchemaField (created by ObjectField)
    in fieldset (created by DefaultObjectFieldTemplate)
    in DefaultObjectFieldTemplate (created by ObjectField)
    in ObjectField (created by SchemaField)
    in div (created by WrapIfAdditional)
    in WrapIfAdditional (created by DefaultTemplate)
    in DefaultTemplate (created by SchemaField)
    in SchemaField (created by Form)
    in form (created by Form)
    in Form (at src/index.js:31)
    in App (at src/index.js:42)

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://fb.me/react-error-boundaries to learn more about error boundaries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant