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

import { WithContext as ReactTags } from 'react-tag-input'; #573

Closed
khoramshahy opened this issue Dec 9, 2019 · 1 comment
Closed

import { WithContext as ReactTags } from 'react-tag-input'; #573

khoramshahy opened this issue Dec 9, 2019 · 1 comment

Comments

@khoramshahy
Copy link

khoramshahy commented Dec 9, 2019

Hi I'v installed your package in my project but when I import it in my component all the component don't load without any error. I'm using hook and my react version is 16.8.6.

it seems the problem is with
import { WithContext as ReactTags } from 'react-tag-input';

my package.json infi is:
"react": "^16.8.6", "react-dom": "^16.8.6", "react-dnd": "^9.3.2", "react-dnd-html5-backend": "^9.3.2","react-tag-input": "^6.4.1",

and my code is :
`
import React, { useState } from 'react';

import { WithContext as ReactTags } from 'react-tag-input';

const KeyCodes = {
comma: 188,
enter: 13,
};

const delimiters = [KeyCodes.comma, KeyCodes.enter];

export default function StepOne(props) {

const [tags, setTags] = useState([
    { id: "Thailand", text: "Thailand" },
    { id: "India", text: "India" }
])
const [suggestions, setSuggestions] = useState([
    { id: 'USA', text: 'USA' },
    { id: 'Germany', text: 'Germany' },
    { id: 'Austria', text: 'Austria' },
    { id: 'Costa Rica', text: 'Costa Rica' },
    { id: 'Sri Lanka', text: 'Sri Lanka' },
    { id: 'Thailand', text: 'Thailand' }
])
handleDelete = (i) => {
    setTags([...tags.filter((tag, index) => index !== i)])
}

handleAddition = (tag) => {
    setTags([...state.tags, tag]);
}

handleDrag = (tag, currPos, newPos) => {
    const tags = [...tags];
    const newTags = tags.slice();

    newTags.splice(currPos, 1);
    newTags.splice(newPos, 0, tag);

    setTags([...newTags]);
}

return (

    <div>
        <ReactTags tags={tags}
            suggestions={suggestions}
            handleDelete={handleDelete}
            handleAddition={handleAddition}
            handleDrag={handleDrag}
            delimiters={delimiters} />
    </div >
);

}`

@jhgv
Copy link

jhgv commented Dec 9, 2019

It seems like it is not supporting react-dnd and react-dnd-html5-backend current versions yet. In my case, I had to downgrade them to:

"react-dnd": "^5.0.0",
"react-dnd-html5-backend": "^3.0.2",

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

2 participants