bucklescript

How to compose props across component in reason-react bindings?

梦想的初衷 提交于 2021-02-07 20:22:08
问题 I am currently writing a material-UI reason-react binding and I want to know how I can re-use previously define Props. The Select component spreads all of the Input props into itself, in the underlying react-js lib. this is done by spreading props however this is discouraged in ReasonML as typings are lost. As a temporary solution, I have copied the props from one to another but this is not scalable. I would appreciate if someone could suggest what is the correct way of doing this in Reason

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

淺唱寂寞╮ 提交于 2021-02-05 09:15:27
问题 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 success. es6-global setting does not change anything. I'm not using a bundling program like webpack. Edit: Possibly relevant thread from Reason forum: https://reasonml.chat/t/can-one-load-reasonml-es6-modules-without-a-bundler/2219 Similar issue

can one load reasonml es6 modules without a bundler

孤者浪人 提交于 2021-01-29 17:10:57
问题 I am trying to use my VSCODDE liver server: https://github.com/ritwickdey/vscode-live-server for development without having to run a (parceljs would be my favorite, since it has hot loading, but it is having issues with reasonml). This almost works, but the the bucklescript compiler expects that the the node-modules to be on the path, and it appears bundlers find them, but not if one does a load this way: es5index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset=utf-8> <link rel

How does fillStyle work in bs-webapi Canvas2d

偶尔善良 提交于 2020-01-25 09:28:07
问题 I'm wondering how to create a and set a fill style using bs-webapi and Canvas2d interface in ReasonML. I think the definition I might need is this: let fillStyle = (ctx: t) => ctx |> fillStyle |> reifyStyle; But I'm having trouble understanding it. I have previously used this project as a source of examples, but I think the bs-webapi has changed since that project was authored. At least the following line modeled after the example: Canvas2d.fillStyle(ctx, "rgba(0,255,255,255)"); gives me this

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

喜夏-厌秋 提交于 2020-01-03 16:45:01
问题 I’m new to reason-react. I’m trying to put a copyright symbol in a react-reason component. I've tried <span >(ReasonReact.stringToElement("©"))</span> but this doesn’t give me the © symbol. 回答1: It's also possible, and usually simpler, to just use the unicode character: let copy = ReasonReact.stringToElement({js|\u00a9|js}); // Since ReasonReact 0.7.0 you can use let copy = React.string({js|\u00a9|js}); Or even shorter: let copy = [%raw {|'\u00a9'|}]; It's also possible to use unicode

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

与世无争的帅哥 提交于 2020-01-01 12:17:32
问题 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 => <strong> <Component ...props/> </strong> Assuming I have some component called HelloMessage , what is the equivalent of this piece of JavaScript: import { withStrong } from './hoc.js'; const HelloMessage = ... const StrongMessage = withStrong(HelloMessage); ReactDOM.render( <StrongMessage name="Joe" />,

How to extend JS class in ReasonML

佐手、 提交于 2019-12-23 12:28:52
问题 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 "TodoAppRe"; let make _children => { ...component, initialState: fun () => {count: 0}, <...> But when i try to write code in this style, i get an error: let myclass unit => { ...mysuperclass, hello: fun () => { Js.log "FooBar"; } }; Error: Unbound

Compile error using fast pipe operator after pipe last in ReasonML

折月煮酒 提交于 2019-12-13 13:41:08
问题 The way that the "fast pipe" operator is compared to the "pipe last" in many places implies that they are drop-in replacements for each other. Want to send a value in as the last parameter to a function? Use pipe last ( |> ). Want to send it as the first parameter? Use fast pipe (once upon a time |. , now deprecated in favour of -> ). So you'd be forgiven for thinking, as I did until earlier today, that the following code would get you the first match out of the regular expression match: Js

OCaml polymorphic recursion errors

烂漫一生 提交于 2019-12-13 03:46:45
问题 Given the following types: type _ task = | Success : 'a -> 'a task | Fail : 'a -> 'a task | Binding : (('a task -> unit) -> unit) -> 'a task | AndThen : ('a -> 'b task) * 'a task -> 'b task | OnError : ('a -> 'b task) * 'a task -> 'b task type _ stack = | NoStack : 'a stack | AndThenStack : ('a -> 'b task) * 'b stack -> 'a stack | OnErrorStack : ('a -> 'b task) * 'b stack -> 'a stack type 'a process = { root: 'a task ; stack: 'a stack } let rec loop : 'a. 'a process -> unit = fun proc ->

What are the Implications of Different ReasonML External Declarations?

亡梦爱人 提交于 2019-12-11 15:49:47
问题 In the examples below, both external declarations achieve the same functionality with slightly different ReasonML function structures. Does external declaration style impact anything (e.g. performance) beyond ReasonML function structure? Also, does ReasonML have a "suggested" external declaration "style"? Type Declarations type dom; type element; External Declaration Style 1 [@bs.val] external dom: dom = "document"; [@bs.send.pipe : dom] external get_by_id: string => element = "getElementById