bs-react-syntax-highlighter
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -0,1 +1,12 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. | ||
### [0.1.1](https://github.com/erykpiast/bs-react-syntax-highlighter/compare/v0.1.0...v0.1.1) (2020-01-01) | ||
### Bug Fixes | ||
* **lint:** change letter case for excluded word ([b5f6695](https://github.com/erykpiast/bs-react-syntax-highlighter/commit/b5f6695b2a4bc347d2711dcab2a77e52ce4d9c60)) | ||
## 0.1.0 (2020-01-01) | ||
@@ -2,0 +13,0 @@ |
{ | ||
"name": "bs-react-syntax-highlighter", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "ReasonML bindings for react-syntax-highlighter library", | ||
@@ -5,0 +5,0 @@ "main": "src/ReactSyntaxHiglighter.re", |
@@ -39,2 +39,27 @@ # bs-react-syntax-highlighter | ||
### Props spread | ||
In JavaScript, there is a possibility to put any property you like on the root element rendered by the component, | ||
by simply putting it on a component. It's called "props spread". `react-syntax-highlighter` supports that pattern as well. | ||
ReasonML [simply can't do it](https://github.com/reasonml/reason-react/blob/master/docs/props-spread.md). | ||
Quite nice escape hatch is wrapping the component you wish to spread props on in another | ||
component (HOC or High-Order Component), which will inject all passed properties to its child in a not type-safe, but quite an efficient way. [source](https://twitter.com/yawaramin/status/1190120664830816256). There is a runtime cost for this operation, though, so I've decided to not include such code in this library. Pay the cost only when you need to. | ||
```reasonml | ||
module Spread = { | ||
[@react.component] | ||
let make = (~props, ~children) => | ||
ReasonReact.cloneElement(children, ~props, [||]); | ||
}; | ||
<Spread props={"id": "foobar"}> | ||
<ReactSyntaxHighlighter.Hljs language={`JavaScript}> | ||
{"const foo = () => {};"} | ||
</ReactSyntaxHighlighter.Hljs>; | ||
</Spread> | ||
``` | ||
For convenience I've included just one such a generic property in component bindings: `className`. | ||
### JSX 2 | ||
@@ -41,0 +66,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
35750
80