Questions tagged [reason-react]

ReasonReact is the official Reason + BuckleScript bindings for ReactJS

ReasonReact (GitHub) is a set of opinionated + bindings for , developed as an open-source project by Facebook.

90 questions
0
votes
2 answers

Making API call and updating state, but getting undefined

I am making an API call, and successfully updating the state. The data from the API looks like this: { "data": [{"name": string}, {"name":string}, ...] } I am making making the API in my didMount lifecycle method. Just for testing, I log the…
benschinn
  • 41
  • 5
0
votes
1 answer

ReasonReact unsafe string to element

I made a function that takes an string and replace a specific substring within it: let mark = (str: string, sub: string) : string => { let re = Js.Re.fromString("(" ++ sub ++ ")"); Js.String.replaceByRe(re, "$1", str); }; It…
Mateus Felipe
  • 1,071
  • 2
  • 19
  • 43
0
votes
1 answer

How to solve in ReasonReact - "This has type: (ReasonReact.reactElement, string) => unit But somewhere wanted: at actElement

I have a very compact ReasonReact reducer component, which has a component, initialState, reducer, action, and render function as follows: type actions = | DoNothing; let component = ReasonReact.reducerComponent("ShowHide"); let make = (~name,…
Charlie-Greenman
  • 1,469
  • 1
  • 16
  • 36
0
votes
1 answer

ReasonReact.Router implementation and serving static files with Express server

I have implemented routing using the Routing feature provided in ReasonReact. It looks like this. It works great, until I have it being served by a node.js express server. It will still route, but when I refresh I get for example cannot GET /about.…
benschinn
  • 41
  • 5
0
votes
1 answer

Type error in render after Promise

I'm trying to render a component with reason-react after I get data from fetch but I receive a type error. This is my code: GetData.re: let get = () => Js.Promise.( Fetch.fetch("localhost:8000/data.json") |> then_(Fetch.Response.json) |>…
SHI1485
  • 121
  • 1
  • 5
0
votes
2 answers

`self.send` on ReasonReact Compile-time Error

Given the following: $cat src/Greeting.re let component = ReasonReact.reducerComponent("Greeting"); type action = | Click; type state = { count: int }; let make = (_children) => { ...component, initialState: () => {count: 0}, reducer:…
Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384
0
votes
1 answer

Focusing an input field in a React component – getting type error trying to create a ref

I have a React component that contains a text element. When the component is mounted, I want the text cursor to be set in the input field, i.e. I want the text input element to have the focus. In a “traditional” JavaScript React component, I…
Patrick Hund
  • 19,163
  • 11
  • 66
  • 95
0
votes
1 answer

Understanding ReasonML/Bucklescript Externals

Just trying to generally understand what is going on here. Does this make sense to explain ReasonApolloTypes.gql as an example of using Externals. This is the bs.module code [@bs.module] external gql : ReasonApolloTypes.gql =…
armand
  • 693
  • 9
  • 29
0
votes
1 answer

reducerComponent can't be found in ReasonReact

I'm trying to follow this Reason React tutorial to build a simple TodoApp: However when changing the type of the component from statelessComponent to reducerComponent I get the following error: We've found a bug for…
Harald Gliebe
  • 7,236
  • 3
  • 33
  • 38
0
votes
2 answers

Why would it matter where a type declaration is located?

The documentation for ReasonReact specifies where in the code a type should be declared: The state type could be anything! An int, a string, a ref or the common record type, which you should declare right before the reducerComponent call: type…
ændrük
  • 782
  • 1
  • 8
  • 22
-1
votes
1 answer

How can we alias props when using the Hooks API?

Previously, I was using [@bs.as "in"] like so. [@bs.deriving abstract] type cssTransitionProps = { [@bs.as "in"] _in: bool, timeout: int, classNames: string, }; How can I do something similar here? module CSSTransition = { [@bs.module…
Raphael Rafatpanah
  • 19,082
  • 25
  • 92
  • 158
-1
votes
2 answers

How do I pass Variants as props to React Components in ReasonML?

I have tried the following approach to be able to send variants as props. type ipAddr = | IPV4 | IPV8; [@react.component] let make = () => { let appData = Data.tileData;
Deadfish
  • 2,047
  • 16
  • 17
-1
votes
1 answer

Managing a form with a lot of fields

I'm writing a form in ReasonReact. I used reducerComponent and a record as state. Let's say I have something like this: type state = { field1: string, field2: int, }; type action = | SetField1(string) | SetField2(int); let component =…
user3139560
  • 19
  • 1
  • 3
-1
votes
1 answer

What does this syntax mean (...)

I'm putting my hands into reason-react. In the following code : let component = ReasonReact.statelessComponent("Component3"); let make = (~name, _children) => { ...component, render: self => , }; I don't understand…
espern
  • 659
  • 6
  • 14
-1
votes
1 answer

Pass arguments to rendered element from HTML

I have a component that I render on HTML based on class, with the function renderToElementWithClassName. I know I can pass values to component in the function (renderToElementWithClassName(, "class");. However, I need to be able…
Mateus Felipe
  • 1,071
  • 2
  • 19
  • 43
1 2 3 4 5
6