Skip to content
This repository was archived by the owner on Nov 20, 2021. It is now read-only.

Commit 010e860

Browse files
author
Ola Holmström
committed
Update README with how to filter
1 parent defc6de commit 010e860

File tree

6 files changed

+32
-11
lines changed

6 files changed

+32
-11
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Highly customizable [React](http://facebook.github.io/react/index.html) componen
2020
* [How do I make the input dynamically grow in size?](#how-do-i-make-the-input-dynamically-grow-in-size)
2121
* [How do I add auto suggestion?](#how-do-i-add-auto-suggestion)
2222
* [How do I control the value of the input box?](#how-do-i-control-the-value-of-the-input-box)
23+
* [How do I fix warning "unknown prop `addTag`"?](#how-do-i-fix-warning-unknown-prop-addtag)
2324
* [Component Interface](#component-interface)
2425
* [Props](#props)
2526
* [value (required)](#value-required)
@@ -180,6 +181,23 @@ class Example extends React.Component {
180181
}
181182
```
182183

184+
##### How do I fix warning "unknown prop `addTag`"?
185+
186+
For ease of integration with auto complete components `react-tagsinput`
187+
passes the `addTag` method to `renderInput` props, if you are writing your
188+
own `renderInput` you need to filter `addTag` to not get an error about
189+
`unknown prop addTag` from React. Here is how it's done in the default
190+
`renderInput` function.
191+
192+
```js
193+
function defaultRenderInput ({addTag, ...props}) {
194+
let {onChange, value, ...other} = props
195+
return (
196+
<input type='text' onChange={onChange} value={value} {...other} />
197+
)
198+
}
199+
```
200+
183201
## Component Interface
184202

185203
### Props

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"react-tagsinput.js",
55
"react-tagsinput.css"
66
],
7-
"version": "3.14.0",
7+
"version": "3.14.2",
88
"homepage": "https://github.com/olahol/react-tagsinput",
99
"description": "Highly customizable React component for inputing tags",
1010
"keywords": [

example/bundle.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4588,11 +4588,13 @@
45884588
getTagDisplayValue: _react2.default.PropTypes.func
45894589
};
45904590

4591-
function defaultRenderInput(props) {
4591+
function defaultRenderInput(_ref) {
4592+
var addTag = _ref.addTag,
4593+
props = _objectWithoutProperties(_ref, ['addTag']);
4594+
45924595
var onChange = props.onChange,
45934596
value = props.value,
4594-
addTag = props.addTag,
4595-
other = _objectWithoutProperties(props, ['onChange', 'value', 'addTag']);
4597+
other = _objectWithoutProperties(props, ['onChange', 'value']);
45964598

45974599
return _react2.default.createElement('input', _extends({ type: 'text', onChange: onChange, value: value }, other));
45984600
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-tagsinput",
3-
"version": "3.14.1",
3+
"version": "3.14.2",
44
"description": "Highly customizable React component for inputing tags",
55
"main": "react-tagsinput.js",
66
"peerDependencies": {

react-tagsinput.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,13 @@
166166
getTagDisplayValue: _react2.default.PropTypes.func
167167
};
168168

169-
function defaultRenderInput(props) {
169+
function defaultRenderInput(_ref) {
170+
var addTag = _ref.addTag,
171+
props = _objectWithoutProperties(_ref, ['addTag']);
172+
170173
var onChange = props.onChange,
171174
value = props.value,
172-
addTag = props.addTag,
173-
other = _objectWithoutProperties(props, ['onChange', 'value', 'addTag']);
175+
other = _objectWithoutProperties(props, ['onChange', 'value']);
174176

175177
return _react2.default.createElement('input', _extends({ type: 'text', onChange: onChange, value: value }, other));
176178
}

src/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ defaultRenderTag.propTypes = {
4545
getTagDisplayValue: React.PropTypes.func
4646
}
4747

48-
function defaultRenderInput (props) {
49-
// eslint-disable-next-line
50-
let {onChange, value, addTag, ...other} = props
48+
function defaultRenderInput ({addTag, ...props}) {
49+
let {onChange, value, ...other} = props
5150
return (
5251
<input type='text' onChange={onChange} value={value} {...other} />
5352
)

0 commit comments

Comments
 (0)