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
2
votes
1 answer

Fetch rejects promise on 404 responses instead of resolving with 404 status

I'm trying to figure out how to process failed http responses in the fetch example in reason-react-example repo. The following was my first idea (tinkering with the url): Js.Promise.( Fetch.fetch("https://dog.ceo/api/breeds/list") …
1
vote
1 answer

How do I use modulus operator in Reason React?

When using the % operator in reason react I am left with an error "The value % can't be found". Is there another word for % used in Reason react? Js.log(20 % 2)
Elissi
  • 312
  • 2
  • 8
1
vote
1 answer

Can I make Reason+React import react module from CDN?

Building a component with Reason and React always gives me an module import statement for "react", which cannot be found if React is included from a CDN. Is there a solution for this? I've tried to define window.react = React in index.html without…
Olle Härstedt
  • 3,799
  • 1
  • 24
  • 57
1
vote
1 answer

Variable number of children

Background: I'm going through an official React tutorial (https://reactjs.org/tutorial/tutorial.html), but in ReasonML (ReasonReact v. 0.9.1). This is a tic-tac-toe game. The classic game is played on a 3x3 board, and I have it working, but now I'm…
Haspemulator
  • 11,050
  • 9
  • 49
  • 76
1
vote
1 answer

How to iterate children obtained from ReactDOMRe.domElementToObj?

I'm trying to implement the FLIP animation technique. I have to access the getBoundingClientRect() of react's element children. let ref = React.useRef(Js.Nullable.null);
{Belt.List.map(items, item => { …
Jakub Zawiślak
  • 5,122
  • 2
  • 16
  • 21
1
vote
1 answer

Getting clientHeight from a react-reason DOM ref

I'm accessing a reason-react DOM reference in order to ascertain client height. Unfortunately clientHeight doesn't seem to be part of the ref API. So this fails: ref -> React.Ref.current -> Js.Nullable.toOption -> Belt.Option.map(this => { …
Peteris
  • 3,548
  • 4
  • 28
  • 44
1
vote
2 answers

Binding to Higher Order Component from aws-amplify

What is bucklescript looking for satisfy the Functions are not valid as a React child. error being produced by the following example. I have this binding to withAuthenticator from aws-amplify-react. [@bs.deriving abstract] type props = { [@bs.as…
1
vote
1 answer

ReasonReact useState with fetched data

I have been using React for a long time and I would like to give a chance to Reason React. I created then a small project to fetch data from a Github repository and then display results. I would like to use React Hooks and store results into my…
Hurobaki
  • 3,728
  • 6
  • 24
  • 41
1
vote
1 answer

What is the syntax to use React fragments in Reason-React

There is this old chat that suggests writing your own fragment wrapper, but I understand that fragment should now be natively supported. However I couldn't quickly find the correct syntax for it. Example of what I'm looking for:
Peter Lamberg
  • 8,151
  • 3
  • 55
  • 69
1
vote
2 answers

Reason React using js component

I'm having trouble with js interop. I'm trying to use a js component react-slick like this: // src/interop/Carousel.js import React from 'react' import Slider from 'react-slick' export function Carousel(props) { return (
Minh Thai
  • 568
  • 6
  • 18
1
vote
1 answer

How to send actions between components?

The documentation explains how to send an action to self however I can't find how to send an action to another component. Right now I'm putting all of my app in a single big reducerComponent but I'd really like to be able to have a menu component…
Thomash
  • 6,339
  • 1
  • 30
  • 50
1
vote
2 answers

How to pass onClick handler from parent to child components through optional labeled arguments

I want to pass an event handler down a series of components from parent to child. Here is a working example: Index.re ReactDOMRe.renderToElementWithId( Js.log("my handler clicked")} />, "root", ); App.re let…
Homan
  • 25,618
  • 22
  • 70
  • 107
1
vote
1 answer

Printing lists with unknown length

I've got a list(string) with an unknown length which I would like to render in my ReasonReact component. I've read that there is no built-in support for printing complex data structures. But how would one go about rendering a list in its component…
Dani
  • 2,448
  • 8
  • 27
  • 44
1
vote
0 answers

reason-react cannot find module bs-platform

Setup I have an existing elixir/phoenix web app with a frontend of vanillajs / React (via react-phoenix). I'm using brunch to bundle everything. Goal I want my existing js react components to be able to import and use reason-react components. I…
AaronCoding
  • 158
  • 1
  • 6
1
vote
1 answer

Error: package reason-react not found or built

After running: bsb -init my-react-login-app -theme react Then, I ran the following to, as I understand, build the project: $npm run build But, I got the following error output: > my-react-login-app@0.1.0 build…
Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384