S
S
Smuzzzzi2018-11-08 15:14:46
React
Smuzzzzi, 2018-11-08 15:14:46

How to fix Unexpected token?

import React from "react";

export default class Chosen extends React.Component {
  componentDidUpdate() {
    // chosen doesn't refresh the options by itself, babysit it
    $(this.refs.select).trigger("chosen:updated");
  }

  handleChange = (a, b, c) => {
    // force the update makes it so that we reset chosen to whatever
    // controlled value the parent dictated
    this.forceUpdate();
    this.props.onChange && this.props.onChange(a, b, c);
  };

  componentDidMount() {
    const props = this.props;
    const select = $(this.refs.select);
    $(select)
      .chosen({
        allow_single_deselect: props.allowSingleDeselect,
        disable_search: props.disableSearch,
        disable_search_threshold: props.disableSearchThreshold,
        enable_split_word_search: props.enableSplitWordSearch,
        inherit_select_classes: props.inheritSelectClasses,
        max_selected_options: props.maxSelectedOptions,
        no_results_text: props.noResultsText,
        placeholder_text_multiple: props.placeholderTextMultiple,
        placeholder_text_single: props.placeholderTextSingle,
        search_contains: props.searchContains,
        single_backstroke_delete: props.singleBackstrokeDelete,
        width: props.width,
        display_disabled_options: props.displayDisabledOptions,
        display_selected_options: props.displaySelectedOptions
      })
      .on("chosen:maxselected", this.props.onMaxSelected)
      .change(this.handleChange);
  }

  componentWillUnmount() {
    $(this.refs.select).off("chosen:maxselected change");
  }

  render() {
    const selectProps = $.extend({}, this.props, { ref: "select" });

    return (
      <div>
        <select {...selectProps}>{this.props.children}</select>
      </div>
    );
  }
}

5be48dc0660f9030565797.png
Unexpected token (47:6)

[0m [90m 45 | [39m    [36mconst[39m selectProps [33m=[39m $[33m.[39mextend({}[33m,[39m [36mthis[39m[33m.[39mprops[33m,[39m { ref[33m:[39m [32m"select"[39m })[0m
[0m [90m 46 | [39m    [36mreturn[39m ([0m
[0m[31m[1m>[22m[39m[90m 47 | [39m      [33m<[39m[33mdiv[39m[33m>[39m[0m
[0m [90m    | [39m      [31m[1m^[22m[39m[0m
[0m [90m 48 | [39m        [33m<[39m[33mselect[39m {[33m...[39mselectProps}[33m>[39m{[36mthis[39m[33m.[39mprops[33m.[39mchildren}[33m<[39m[33m/[39m[33mselect[39m[33m>[39m[0m
[0m [90m 49 | [39m      [33m<[39m[33m/[39m[33mdiv[39m[33m>[39m[0m
[0m [90m 50 | [39m    )[0m

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-11-08
@Smuzzzzi

What am I doing wrong?

Trying to rape a corpse - the component has not been updated for three years. Either find something fresher, or rewrite it yourself (there is work for about five minutes, no more).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question