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
8
votes
4 answers

How to add a copyright symbol in reason-react component?

I’m new to reason-react. I’m trying to put a copyright symbol in a react-reason component. I've tried (ReasonReact.stringToElement("©")) but this doesn’t give me the © symbol.
bonheury
  • 362
  • 1
  • 5
  • 14
5
votes
1 answer

How to bind to and use a higher-order component in ReasonReact

Let's say I have a higher-order component, something like the following trivial definition, exported from the JavaScript module ./hoc.js: export const withStrong = Component => props => Assuming I have…
glennsl
  • 28,186
  • 12
  • 57
  • 75
5
votes
2 answers

Reason React and Graphql handling ENUM values

Just started to learn reason react and struggle with a graphql setup trying to read an ENUM value. setup reason react apollo graphql graphql_ppx github graphql endpoint i am fetching the latest pull request data over the github api and reading the…
roman
  • 889
  • 9
  • 16
5
votes
2 answers

How to handle global DOM events in ReasonML/ReasonReact?

What's the most idiomatic way of listening/handling global DOM events in ReasonML. I'm building a ReasonReact version of the 2048 game where I need to listen for keyboard events. In a standard JS/React app I'd have a component with a…
Alan R. Soares
  • 1,735
  • 1
  • 15
  • 19
5
votes
1 answer

Error while compiling reducerComponent "Is this a ReasonReact reducerComponent or component with retained props?"

I'm getting an error when creating a reducerComponent: Code type state = {repoData: RepoData.repo}; let dummyRepo: RepoData.repo = { stargazers_count: 27, full_name: "jsdf/reason-react-hacker-news", html_url:…
Ashley Coolman
  • 11,095
  • 5
  • 59
  • 81
5
votes
2 answers

How to add custom method to ReasonReact component?

I am very new to ReasonML. I am able to successfully create a stateless component with ReasonReact, but I have not figured out how I might add a custom method to the component (e.g. Next.js' static getInitialProps). When attempting to define the…
David
  • 1,330
  • 17
  • 31
4
votes
1 answer

useEffect vs useEffect0 in ReasonML

I am trying understand what the difference is between: React.useEffect(() => { let timerId = Js.Global.setInterval(() => tick(), 1000); Some(() => Js.Global.clearInterval(timerId)); }); React.useEffect0(() => { let timerId =…
armand
  • 693
  • 9
  • 29
4
votes
1 answer

How to conditionally render reason-react component?

Something that has started appearing in my code quite a bit is: {if (condition) { ; } else {
; }} ; Basically I only want the Child to render if the condition is true, otherwise…
JasoonS
  • 1,432
  • 3
  • 13
  • 26
4
votes
2 answers

How to define a binding that accepts multiple types in the function signature using reason-react?

When defining a reason-react binding and I want to know how I can determine a binding that accepts multiple types. For example, I have an argument ~value that should accept: string, number, array(string) or array(number). At the moment I am using…
user465374
  • 1,521
  • 4
  • 20
  • 39
4
votes
1 answer

How to extend JS class in ReasonML

For example, I have an es6-like class: class Foo {...} And I want to extend it: class Bar extends Foo {...} In reason-react documentation I found examples, but I'm not sure that it's appropriate for me: let component = ReasonReact.reducerComponent…
S. Zobov
  • 154
  • 2
  • 15
3
votes
1 answer

How to extend HTML attribute interfaces when designing reasonml react components?

I'm learning reasonml and quite excited about it. Something I often do in typescript react code is: type Props = React.HTMLProps & { foo: boolean } const SuperButton: React.FC = (props) =>
3
votes
1 answer

How can I destructure a tuple into a List.map in ReasonML?

let numbers = [1, 5, 6, 12, 52, 25]; let state: list((int, bool)) = numbers |> List.map(n => (n, false)); state |>…
sheki
  • 8,991
  • 13
  • 50
  • 69
3
votes
1 answer

How to display emojis with ReasonReact?

Is there an easy way to insert emojis with ReasonReact? In ReactJS, you can simply type the emoji and it renders as expected, but that doesn't seem to be the case in Reason. If you try this: {React.string("")}…
user11305879
3
votes
1 answer

Inheriting Nextjs App component (pages/_app.js) in ReasonReact

I'm trying to implement the React Context API in my Nextjs app using ReasonReact but getting caught out by the bucklescript compiler's way of inferring module names. To make the context available to the whole tree I need to inherit from the Nextjs…
Julian Suggate
  • 627
  • 1
  • 6
  • 14
3
votes
1 answer

action has wrong type in ReasonReact reducer

I'm trying to create a simple todo app, this is an input component and I need a reducer to update the state of the input. This code is throwing the error - This pattern matches values of type action but a pattern was expected which matches values of…
coops22
  • 401
  • 7
  • 15
1
2 3 4 5 6