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

TypeError: Cannot read properties of null (reading 'style') #27

Open
maurobilotti opened this issue Sep 22, 2021 · 0 comments
Open

TypeError: Cannot read properties of null (reading 'style') #27

maurobilotti opened this issue Sep 22, 2021 · 0 comments

Comments

@maurobilotti
Copy link

maurobilotti commented Sep 22, 2021

Hi,

I have found an issue today working with the React Icon Picker component.

2021-09-22 16_17_36-Window

I had to overwrite the "absolute" position on one of the classes of the component but I'm not sure that's the reason.

The definition of my component looks this way: (ignoring the whole list of font-awesome icons)


const fontAwesomeIcons = { 
  //whole object of font-awesome icons that can be found on the demo
  //https://github.com/fontIconPicker/react-fonticonpicker/blob/master/src/docs/helpers/iconDefs.js
}

type IconPickerProps = {
  value?: string;
  onChange?: (value?: string) => void;
};

const styles = {
  "@global": {
    ".rfipdropdown": {
      position: "relative", 
    },
  },
};

const IconPicker = ({ value, onChange }: IconPickerProps) => {
  const [icon, setIcon] = useState<string | undefined>(value);

  const iconChange = (value?: string | undefined) => {
    setIcon(value);
    if (onChange !== undefined) onChange(value)!;
  };

  const pickerProps = {
    icons: [
      ...fontAwesomeIcons.Accessibility,
      ...fontAwesomeIcons.Arrows,
      ...fontAwesomeIcons["Audio & Video"],
      ...fontAwesomeIcons.Business,
      ...fontAwesomeIcons.Chess,
      ...fontAwesomeIcons.Code,
      ...fontAwesomeIcons.Communication,
      ...fontAwesomeIcons.Computers,
      ...fontAwesomeIcons.Currency,
      ...fontAwesomeIcons["Date & Time"],
      ...fontAwesomeIcons.Design,
      ...fontAwesomeIcons.Editors,
      ...fontAwesomeIcons.Files,
      ...fontAwesomeIcons.Genders,
      ...fontAwesomeIcons.Hands,
      ...fontAwesomeIcons.Health,
      ...fontAwesomeIcons.Images,
      ...fontAwesomeIcons.Interfaces,
      ...fontAwesomeIcons.Maps,
      ...fontAwesomeIcons.Objects,
      ...fontAwesomeIcons["Payments & Shopping"],
      ...fontAwesomeIcons.Shapes,
      ...fontAwesomeIcons.Spinners,
      ...fontAwesomeIcons.Sports,
      ...fontAwesomeIcons.Status,
      ...fontAwesomeIcons["Users & People"],
      ...fontAwesomeIcons.Vehicles,
      ...fontAwesomeIcons.Writing,
    ],
    theme: "bluegrey",
    renderUsing: "class",
    value: icon,
    onChange: iconChange,
    isMulti: false,
    noSelectedPlaceholder: "Pick icon"
  };

  return (
    <>
      <FontIconPicker {...pickerProps} />
    </>
  );
};

export default withStyles(styles)(IconPicker);

The error apears when scrolling up/down faster.
Can you please take a look and suggest what could be the issue?

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