Posts

Showing posts from 2018

thougthfulness of facebook's reasonml and reasonreact

Facebook recently released 0.3 version of reason and reasonreact for creating UIs. Instead of using typescript, you would use reasonml. reasonml is based on OCaml which has both functional and OOP capabilities. Why is how facebook is integrating reasonml into their ecosystem brillant? facebook recognizes that the ocaml syntax is a burden to learn. reasonml is a more javascript oriented syntax of ocaml. ocaml syntax is, as many functional languages are, harder to learn than say google’s go or really it’s difficult if you are not used to functional syntax. syntax is a big burden for migration of existing devs. The great part is that they are making it easy for a certain group, such as js programmers, to migrate.facebook has created reasonreact using only a subset of ocaml. No OOP components. And they reduce the surface area of the reactjs APIs to something appropriate for the functional world. The API is small and easy to learn. It does not offer everything that the reactjs API offers b…

codemirror, react and height sizing.md

codemirror, react and height sizing.mdIf you use codemirror and react together, say through react-codemirror2, then you may have run into sizing issues.Out of the box, codemirror has a style height setting to 300px on the outer div with classname CodeMirror. react-codemirror2 wraps this with another div called react-codemirror2.If you don’t load the CSS correctly, the default height of the component is 300px, which is rarely what you want. You generally want the editor to resize based on your overall layout. However, you may have found it difficult to do so. I certrainly did.The secret is to realize that codemirror add its own scrollbars and manages scrolling in order to optimize content rendering. There are really two modes for setting the height:Set the size of the outer container explicitly with a hight, say 500px using editor.setSize() however this does not refresh when the page changes size.Allow for dynamic resizing but ensure that the the component knows how tall it is.Generall…

pass through from typescript to babel.md

pass through from typescript to babel.mdI often use typescript just for types and not for bundling or transpilation to different ES targets.Typescript can play a few different roles that when used with a complex stack, can cause tooling confusion. To avoid confusion, I generally have typescript do as little as possible.To have typescript passthrough everything to babel, which is configured to transpile down to my target, I set tsconfig.json to:module: esnext => target an ES version that understands import/export natively.moduleResolution: node => resolve modules using node semantics. This is the default, but when “module” is used, it seems to get reset to a bad value.target: esnext => target the latest es environment for destructuring, default args, etc.jsx: preserve: => Keep brackets (see below).importHelpers; true => If typescript does happen to transpile, import tslib instead of writing some boilerplate into each output module. This saves spacenoEmitHelpers: true =&g…