react-color icon indicating copy to clipboard operation
react-color copied to clipboard

Uncaught TypeError: Cannot read property 'isValidHex' of undefined

Open pavelthq opened this issue 4 years ago • 1 comments

When using with webpack since 2.19.3 it breaks when:

import color from 'react-color/lib/helpers/color'


... then in code use:
    color.isValidHex(data.hex)

causes error.

I guess it is because in color.js there are:

exports.isvalidColorString = exports.red = exports.getContrastingColor = exports.isValidHex = exports.toState = exports.simpleCheckForValidColor = undefined;

pavelthq avatar Feb 24 '21 12:02 pavelthq

Ok I see now you have explicitly import exact method like:

import { isValidHex } from 'react-color/lib/helpers/color'

Thanks.

pavelthq avatar Feb 24 '21 12:02 pavelthq