Questions tagged [bucklescript]

BuckleScript was previously known as a compiler for compiling OCaml to efficient JavaScript code. It has now evolved into the ReScript language. Use the [rescript] tag instead.

BuckleScript was previously known as a back-end for which emits readable, modular and highly performant JavaScript.

On July 2020, BuckleScript (and some parts of the ReasonML syntax) evolved into the ReScript language platform. The term "BuckleScript" is therefore deprecated. Use the tag for BuckleScript specific questions instead.

Useful resources

Related tags

181 questions
1
vote
1 answer

How to defined data type for nested recursive data

I got a data from js side, it looks like this { "selectionSet": { "type": 1, "selections": [ { "name": { "kind": "Name", "value": "viewer" }, …
Shuumatsu
  • 592
  • 2
  • 5
  • 12
1
vote
1 answer

Interval clearing itself in Reason

In Reason, what would be the most elegant way of having an interval that clears itself when some condition is satisfied? In JavaScript I could do: var myInterval = setInterval(function () { // do some stuff if (fancyCondition) { …
noziar
  • 1,017
  • 7
  • 11
1
vote
2 answers

How to share data between two event handler?

I'm playing with reason and buckelscript, and as an exercise I created bindings for http.get (https://nodejs.org/docs/latest-v8.x/api/http.html#http_http_get_options_callback) Using this bindings I would like to code this simple…
ThomasThiebaud
  • 11,331
  • 6
  • 54
  • 77
1
vote
0 answers

Getting error 'variant constructor can't be found' while compiling

I was trying out use a sortable list component (react-sortable-hoc) on a ReasonReact project. But I ran into an error which I was trying to figure out for couple of hours. Steps I followed: made the @bs binds for sortableContainer() and…
Jaison Justus
  • 2,753
  • 8
  • 47
  • 65
1
vote
1 answer

Ocaml : using records and variants in argument types

As a newbie in Ocaml, I'm playing with type and try to understand how variants work. Here is the sample : type 'a component = { foo : int; bar : 'a } type string_or_float_component = | Str of string component | Flt of float component let…
Tiramitsu
  • 61
  • 10
1
vote
1 answer

Decoding a JSON array of objects

Let's say I have this JSON array of objects: [ {"name": "foo", "tags": ["bird", "animal"], "age": 10}, {"name": "bar", "tags": ["dog", "animal"], "age": 5}, {"name": "baz", "tags": ["cat", "animal"], "age": 3} ] How can I decode this in…
Rotareti
  • 49,483
  • 23
  • 112
  • 108
1
vote
1 answer

"You may need an appropriate loader to handle this file type" with bsb react template

I have a file View.js, that contains a stateless component: import Button from 'material-ui/Button'; import React from 'react'; const View = (props) => (
); export…
softshipper
  • 32,463
  • 51
  • 192
  • 400
1
vote
1 answer

Capitalized field name in record

Is it possible to make a record with a capitalized field name? something like: [@bs.deriving jsConverter] type coordinates = { X: int, Y: int }; The reason I ask is because the js object I'm interfacing with has capitalized keys. Here's the…
GTDev
  • 5,488
  • 9
  • 49
  • 84
1
vote
1 answer

How to use JS functions/variables defined in another file?

Currently I have a file src/index.re. I also have a file src/util.js which defines some helper functions I’d like to use. How do I use those functions in src/index.re?
Derek Chiang
  • 3,330
  • 6
  • 27
  • 34
1
vote
1 answer

Can't resolve ReasonReact.js in webpack

I'm trying to get ReasonML working with an existing React code base. I'm not using create-react-app. This is a hand-built project. For the most part, it looks like everything is set up fine. However, I'm getting an error when I try to run Webpack…
jsc
  • 13
  • 2
1
vote
1 answer

Decode a json tree structure

In the bs-json library there is an example provided for converting a json structure to a tree using the andThen combinator. The original example can be found here on github in the ML interface file. Copying the function decodeTree from this file to…
jcsherin
  • 368
  • 1
  • 6
1
vote
2 answers

How to defined component /binding when using React ref in Reasonml?

I am having issues integrating react-system-notification module in my app, having read the documentation about Reason React Ref I am not sure why the reference is not passed down the stack; a hint would be much appreciated. I keep getting the error…
user465374
  • 1,521
  • 4
  • 20
  • 39
1
vote
2 answers

Documentation generation for BuckleScript project

Is there any way to generate code documentation for BuckleScript or Reason? I've tried using ocamldoc, but I don't know how to include node package dependencies automatically.
henoc
  • 183
  • 1
  • 9
1
vote
1 answer

Pass results of querySelectorAll to EventTarget.addEventListener

I want to do something like: open Webapi.Dom; let addListener = (element) => EventTarget.addEventListener("click", onSubscribeClick, EventTarget.asEventTarget(element)); let addOrRemoveListeners = (handler, ()) => { let elements =…
Javier Chávarri
  • 1,605
  • 11
  • 21
1
vote
2 answers

Graphql array response to ReasonReact

Trying to figure working with data in reason. I have this graphql query returning data a logging it. Question is how do I access the data in the following component. let component = ReasonReact.statelessComponent("Home"); let make = (_) => { …
armand
  • 693
  • 9
  • 29