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

React 17 Cannot read properties of null #74

Open
immakdas opened this issue Dec 3, 2022 · 1 comment
Open

React 17 Cannot read properties of null #74

immakdas opened this issue Dec 3, 2022 · 1 comment

Comments

@immakdas
Copy link

immakdas commented Dec 3, 2022

In react error click
<input name="thename" type="text" value="#0f0" onclick={(new CP(document.querySelector(input[name="thename"])))
error Cannot read properties of null (reading 'append')

@taufik-nurrohman
Copy link
Owner

taufik-nurrohman commented Dec 4, 2022

It should not be used like that. You should go with component and create a virtual element such as ColorPicker and handle the events from there.

class ColorPicker extends React.Component {
    constructor() {
        this.picker = new CP(/* ... */);
    }
    handleFocus = () => {
        this.picker.enter();
    }
    render() {
        return (
            <input onClick={this.handleFocus}/>
        );
    }
}

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