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

jsx-handler-names not works well with stateless components #346

Closed
playpauseandstop opened this issue Dec 2, 2015 · 1 comment
Closed

Comments

@playpauseandstop
Copy link

I enabled react/jsx-handler-names rule today for my codebase and everything went well, except one case with stateless component for modal. I put all handlers there in props and from docs it shouldn't consider warnings, but it does.

Next code,

import React, {PropTypes} from "react";
import {Button, Modal} from "react-bootstrap";

const ClearChangesModal = (props) => {
    return (
        <Modal onHide={props.onClose} show>
            <Modal.Body>
                <p>Are You Sure to discard all changes?</p>
                <p className="text-danger">This action is undone.</p>
            </Modal.Body>
            <Modal.Footer>
                <Button onClick={props.onClose}>Cancel</Button>
                <Button bsStyle="danger" onClick={props.onClear}>
                    Discard
                </Button>
            </Modal.Footer>
        </Modal>
    );
};

ClearChangesModal.propTypes = {
    onClear: PropTypes.func.isRequired,
    onClose: PropTypes.func.isRequired
};

export default ClearChangesModal;

gives me,

  10:16  error  Handler function for onHide prop key must be named handleHide    react/jsx-handler-names
  19:25  error  Handler function for onClick prop key must be named handleClick  react/jsx-handler-names
  20:42  error  Handler function for onClick prop key must be named handleClick  react/jsx-handler-names

which is wrong, I suppose.

For now I disabled react/jsx-handler-names rule in the component, but hope you can fix it soon. Thanks!

@andrewdelprete
Copy link

Good call, I just ran across this myself, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants