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

Module not found: Can't resolve './Constants' in 'D:\desktop\ant_design_pro\onefox\src\components\Drag' #1055

Closed
yaoyuande opened this issue Jun 2, 2018 · 3 comments

Comments

@yaoyuande
Copy link

Describe the bug
A clear and concise description of what the bug is.
Module not found: Can't resolve './Constants' in 'D:\desktop\ant_design_pro\onefox\src\components\Drag'
To Reproduce
Steps to reproduce the behavior:
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { DragSource } from 'react-dnd';
import { ItemTypes } from './Constants';

Where is the Constants? How can I import the ItemTypes ?
Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Browser chrome

Additional context
Add any other context about the problem here.

@atfzl
Copy link

atfzl commented Jun 2, 2018

@yaoyuande seems like this issue is not related to react-dnd.

@amazingmarvin
Copy link

amazingmarvin commented Jun 2, 2018

In react-dnd, every drag source has a type. And what the types are depend on what you're dragging in your program. So in my app I have types "task" and "project", but you might have "contact" and "organization". If you don't want to type out these strings all the time (since you might misspell theme), you can store them all in a file:

// Constants.js
export default {
  CONTACT: "contact",
  ORGANIZATION: "organization",
};

then in your e.g. Drag/Contact.js you would use:

import ItemTypes from "./Constants";

class Contact extends Component {
  ...
}

Contact = DragSource(ItemTypes.CONTACT, ...)(Contact);
export { Contact };

It looks like your problem is that you didn't create a Constants.js file or it isn't in the Drag directory on your PC!

@yaoyuande
Copy link
Author

@amazingmarvin Thank you very much!

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