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

ESLint: Declare only one React component per file(react/no-multi-comp) #67

Open
mdodge-ecgrow opened this issue Jul 1, 2021 · 0 comments

Comments

@mdodge-ecgrow
Copy link

mdodge-ecgrow commented Jul 1, 2021

I am using this library throughout my application. It works beautifully! But I keep getting these ESLint errors when I use it. The two errors I usually get are: ESLint: Declare only one React component per file(react/no-multi-comp) and ESLint: Component definition is missing display name(react/display-name).

And here is an example of the code that is throwing those two errors (this is a function inside one of my components):

const deleteComment = (id) => {
	confirmAlert({
		customUI: ({ onClose }) => {
			return (
				<div className={'custom-ui-dialog'}>
					<h1>Confirm Remove Comment</h1>
					<div className={'body'}>
						<h3>Are you sure you want to remove this comment?</h3>
						<div className={'buttons'}>
							<button onClick={onClose}>No</button>
							<button
								onClick={() => {
									deleteCommentAPI(id).then(() => {
										onClose();
									});
								}}
							>
								Yes
							</button>
						</div>
					</div>
				</div>
			);
		},
		closeOnEscape: false,
		closeOnClickOutside: false,
	});
};

The error shows specifically on this line: customUI: ({ onClose }) => {.

While it does not appear to be causing any real issues, I would love to be able to clean up those errors and get this fixed.

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