0

I followed both the documentation, and the solution found here, on SO. But the input field just wouldn't load on localhost. It does however if I just add it into an index.html file.

<script async src="https://cse.google.com/cse.js?cx=123456">
</script>
<div class="gcse-search"></div>

Does anybody know what might cause it?

Things I tried:

  1. Added it to my page as displayed above.
  2. Added the script tag separately into the head tag.
  3. Added the script as a function into the ComponentDidMount
7
  • 1
    The accepted answer's solution works for me: codesandbox.io/s/react-cascading-select-forked-5nzssf?file=/src/… Commented Jul 27, 2022 at 7:10
  • I figured out, that it needs to be served statically, but I don't know why. Does anybody have an answer to that? Commented Jul 27, 2022 at 7:10
  • Does this answer your question? How to embed Google Custom Search in React App? Commented Jul 27, 2022 at 7:32
  • Nope, I literally linked it in my question. Commented Jul 27, 2022 at 9:55
  • 1
    Haha, you're right! Fixed. Anyway, the "Does this answer your question?" nonsense gets added automatically when you mark as dupe and I was too lazy to edit it. The point is: I know you linked to it but the proposed solution of adding the script to <head> does work. Commented Jul 28, 2022 at 9:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.