PasteRack.org
Paste # 61466
2019-06-10 10:34:07

Fork as a new paste.

Paste viewed 550 times.


Embed:

#lang racket
   (define (SearchResults props)
     (use-state query set-query "a search term")
     (use-state data  set-data  (object [hits (array)]))

     (useEffect (λ ()
                  (var [promise (axios (+ "http://hn.algolia.com/api/v1/search?query=" query))])
                  (dot promise (then (λ (response)
                                       (console.log response)
                                       (set-data response.data))))
                  undefined)
                (array query))

     (var [names (array "foo" "bar")])
     
     (create (div nil
                  (p nil ,query)
                  (ul nil ,(for/array ([hit in-array    (ref/default data "hits" (array))])
                             (create (li (object [key hit.objectID])
                                         (a (object [href hit.url])
                                            ,hit.title)))))
                  (input (object [value query]
                                 [onChange (λ(e) (set-query e.target.value))])))))
   
   (ReactDOM.render (create (div nil
                                 (Greeting nil "Hello, world!")
                                 (Todos nil (object [todos (array "foo" "bar")]))
                                 (SearchResults nil "ignored")))
     (document.getElementById "root"))
   )

=>

prog:30:3: read: unexpected `)'
  context...:
   /home/pasterack/racket68/collects/syntax/module-reader.rkt:186:17: body
   /home/pasterack/racket68/collects/syntax/module-reader.rkt:183:2: wrap-internal
   /home/pasterack/racket68/collects/racket/../syntax/module-reader.rkt:65:9: lang:read-syntax
   /home/pasterack/racket68/share/pkgs/scribble-lib/scribble/private/manual-code.rkt:112:0: get-tokens
   /home/pasterack/racket68/share/pkgs/scribble-lib/scribble/private/manual-code.rkt:56:0: typeset-code15
   /home/pasterack/pasterack/tmp/61466/61466code.scrbl: [running body]
   loop
   ...cket/cmdline.rkt:179:51
   /home/pasterack/racket68/share/pkgs/scribble-lib/scribble/run.rkt: [running body]