0
votes

This is the error message I'm getting :

Cannot read properties of undefined (reading 'change')

enter image description here

This is how I'm calling selectize change method :

this.selectize.on('change', this.onChange);

Here, onChange is a prop, which calls the onSubmit method of react-final-form, and onSubmit definition is as below :

 const onSubmit = ({ content, url }, { reset }) => { 
    if (content) {
      const action = !content.get('campaignId') ? addContent : addCampaign;

      return action(content).then(() => {
        reset();

        if (contentSelector && contentSelector.current) {
          contentSelector.current.exclude(
            content.get('id') || content.get('campaignId')
          );
          contentSelector.current.selectize.blur();
        }
      });
    }

    if (url) {
      return addExternal(url).then(reset);
    }

    return null;
  };