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.

Cannot type TagInput onChange as string[]

See original GitHub issue

Environment

  • Package version(s): "@blueprintjs/core": 3.15.1
  • Browser and OS versions: N/A

Minimal repro: https://codesandbox.io/s/2pz12p278r?fontsize=14

Steps to reproduce

  1. Use <TagInput /> with strict: true and onChange: (newValues: string[]) => ...

Actual behavior

Type '(newValues: string[]) => void' is not assignable to type '(values: ReactNode[]) => boolean | void'.
  Types of parameters 'newValues' and 'values' are incompatible.
    Type 'ReactNode[]' is not assignable to type 'string[]'.
      Type 'ReactNode' is not assignable to type 'string'.
        Type 'undefined' is not assignable to type 'string'.ts(2322)

Expected behavior

A way of typing the onChange callback without getting type errors.

Possible solution

Maybe <TagInput<string[]> />? Or maybe this is fixable in the current typings.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
thelastnodecommented, Apr 16, 2019

Could a generic component with React.ReactNode[] default work? I think that would be a non-breaking change.


interface ITagInputProps<T> {
    values: T[];
    onChange: (values: T[]) => boolean | void;
}

class TagInput<T = React.ReactNode[]> extends React.Component<ITagInputProps<T>> {
}
0reactions
adidahiyacommented, Jan 13, 2021

There have been some recent changes to the TagInput API… closing this issue in favor of https://github.com/palantir/blueprint/issues/4390

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't type in React input text field - Stack Overflow
It needs to be onChange in JSX. <input type="text" value={this.props.searchString} ref="searchStringInput ...
Read more >
Building a tag input field component for React - LogRocket Blog
Ever wonder how to build a tag input field component for your React app? Here's a quick tutorial to show you exactly how...
Read more >
<input type="text"> - HTML: HyperText Markup Language | MDN
A string representing the text contained in the text field. Events, change and input. Supported Common Attributes, autocomplete , list , ...
Read more >
ngx-chips - npm
Tag Input Component for Angular Build Status npm version ... String that sets the placeholder of the input for entering new terms.
Read more >
Form Tags | Components - BootstrapVue
disableAddButton, Boolean, Will be true if the tag(s) in the input cannot be added (all invalid ... form, String, The form attribute for...
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