Comparing version 4.0.1 to 4.1.0
# Changelog | ||
## 4.1.0 | ||
Pass thru the export for React's `useContext` hook. | ||
## 4.0.1 | ||
Fixed bug with use of `key` prop with components created using `fromClass`. | ||
## 3.2.1 | ||
@@ -12,3 +20,3 @@ | ||
Only Kefir properties, in other words, objects that inherit `Kefir.Property`, | ||
are lifted. `Kefir.Stream` and `Kefir.Observable` objects are not lifted and | ||
are lifted. `Kefir.Stream` and `Kefir.Observable` objects are not lifted and | ||
will result in errors. | ||
@@ -15,0 +23,0 @@ |
@@ -151,3 +151,4 @@ 'use strict'; | ||
exports.forwardRef = React.forwardRef; | ||
exports.useContext = React.useContext; | ||
exports.createElement = createElement; | ||
exports.fromClass = fromClass; |
import { inherit, object0, isString, dissocPartialU, assocPartialU } from 'infestines'; | ||
import { when, toFunction, flatten, ifElse, identity, values, branchOr, elems, choose, forEach, modify, get } from 'partial.lenses'; | ||
import { Component, Fragment, createElement, forwardRef } from 'react'; | ||
export { Children, Fragment, createContext, forwardRef } from 'react'; | ||
export { Children, Fragment, createContext, forwardRef, useContext } from 'react'; | ||
import { Property } from 'kefir'; | ||
@@ -6,0 +6,0 @@ |
@@ -148,2 +148,3 @@ (function (global, factory) { | ||
exports.forwardRef = React.forwardRef; | ||
exports.useContext = React.useContext; | ||
exports.createElement = createElement; | ||
@@ -150,0 +151,0 @@ exports.fromClass = fromClass; |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("infestines"),require("partial.lenses"),require("react"),require("kefir")):"function"==typeof define&&define.amd?define(["exports","infestines","partial.lenses","react","kefir"],n):n(e.karet={},e.I,e.L,e.React,e.Kefir)}(this,function(e,f,u,c,n){"use strict";function t(e){var n=e._currentEvent;if(n)return n.value}function r(t,e){var n=e.args,r=t.h;r||(r=t.h=function(e){var n=e.type;if("value"===n)t.forceUpdate();else if("error"===n)throw e.value}),u.forEach(function(e){return e.onAny(r)},m,n)}function o(e,n){var t=e.h;u.forEach(function(e){return e.offAny(t)},m,n.args)}function i(e,n,t){for(;e<0;++e)n.offAny(t.h);for(;0<e;--e)n.onAny(t.h)}var l="karet-lift",s=function(e){return e instanceof n.Property},a=u.when(s),p=u.toFunction([u.flatten,a]),h=u.ifElse(s,u.identity,[u.values,a]),d=u.branchOr(a,{children:p,style:h,dangerouslySetInnerHTML:h}),m=u.toFunction([u.elems,u.choose(function(e,n){return 1<n?p:1===n?d:a})]),y="undefined"==typeof window?{h:null,forceUpdate:function(){}}:null,g=f.inherit(function(e){c.Component.call(this,e),(this.h=y)&&(this.state=f.object0)},c.Component,{componentDidMount:function(){r(this,this.props)},componentDidUpdate:function(e){var n=new Map;n.h=this.h,u.forEach(function(e){return n.set(e,(n.get(e)||0)-1)},m,e.args),u.forEach(function(e){return n.set(e,(n.get(e)||0)+1)},m,this.props.args),n.forEach(i)},componentWillUnmount:function(){o(this,this.props)},render:function(){if(this.h){var e=u.modify(m,t,this.props.args);return e[0]===c.Fragment&&e.length<3?null:c.createElement.apply(null,e)}return null}},y&&{getDerivedStateFromProps:function(e){return r(y,e),o(y,e),null}});e.Children=c.Children,e.Fragment=c.Fragment,e.createContext=c.createContext,e.forwardRef=c.forwardRef,e.createElement=function(e,n,t){var r=(n=n||f.object0)[l];if(r||f.isString(e)||c.Fragment===e||s(e)){var o=arguments.length,i=Array(o);i[0]=e,i[1]=r?f.dissocPartialU(l,n):n;for(var a=2;a<o;++a)i[a]=arguments[a];return u.get(m,i)?c.createElement(g,{args:i,key:n.key}):c.createElement.apply(null,i)}return c.createElement.apply(null,arguments)},e.fromClass=function(r){return c.forwardRef(function(e,n){var t=[r,null==n?e:f.assocPartialU("ref",n,e)];return u.get(m,t)?c.createElement(g,{args:t}):c.createElement.apply(null,t)})},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("infestines"),require("partial.lenses"),require("react"),require("kefir")):"function"==typeof define&&define.amd?define(["exports","infestines","partial.lenses","react","kefir"],n):n(e.karet={},e.I,e.L,e.React,e.Kefir)}(this,function(e,f,u,c,n){"use strict";function t(e){var n=e._currentEvent;if(n)return n.value}function r(t,e){var n=e.args,r=t.h;r||(r=t.h=function(e){var n=e.type;if("value"===n)t.forceUpdate();else if("error"===n)throw e.value}),u.forEach(function(e){return e.onAny(r)},m,n)}function o(e,n){var t=e.h;u.forEach(function(e){return e.offAny(t)},m,n.args)}function i(e,n,t){for(;e<0;++e)n.offAny(t.h);for(;0<e;--e)n.onAny(t.h)}var l="karet-lift",s=function(e){return e instanceof n.Property},a=u.when(s),p=u.toFunction([u.flatten,a]),h=u.ifElse(s,u.identity,[u.values,a]),d=u.branchOr(a,{children:p,style:h,dangerouslySetInnerHTML:h}),m=u.toFunction([u.elems,u.choose(function(e,n){return 1<n?p:1===n?d:a})]),y="undefined"==typeof window?{h:null,forceUpdate:function(){}}:null,g=f.inherit(function(e){c.Component.call(this,e),(this.h=y)&&(this.state=f.object0)},c.Component,{componentDidMount:function(){r(this,this.props)},componentDidUpdate:function(e){var n=new Map;n.h=this.h,u.forEach(function(e){return n.set(e,(n.get(e)||0)-1)},m,e.args),u.forEach(function(e){return n.set(e,(n.get(e)||0)+1)},m,this.props.args),n.forEach(i)},componentWillUnmount:function(){o(this,this.props)},render:function(){if(this.h){var e=u.modify(m,t,this.props.args);return e[0]===c.Fragment&&e.length<3?null:c.createElement.apply(null,e)}return null}},y&&{getDerivedStateFromProps:function(e){return r(y,e),o(y,e),null}});e.Children=c.Children,e.Fragment=c.Fragment,e.createContext=c.createContext,e.forwardRef=c.forwardRef,e.useContext=c.useContext,e.createElement=function(e,n,t){var r=(n=n||f.object0)[l];if(r||f.isString(e)||c.Fragment===e||s(e)){var o=arguments.length,i=Array(o);i[0]=e,i[1]=r?f.dissocPartialU(l,n):n;for(var a=2;a<o;++a)i[a]=arguments[a];return u.get(m,i)?c.createElement(g,{args:i,key:n.key}):c.createElement.apply(null,i)}return c.createElement.apply(null,arguments)},e.fromClass=function(r){return c.forwardRef(function(e,n){var t=[r,null==n?e:f.assocPartialU("ref",n,e)];return u.get(m,t)?c.createElement(g,{args:t}):c.createElement.apply(null,t)})},Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -1,9 +0,9 @@ | ||
Copyright � 2016 Vesa Karvonen | ||
Copyright © 2016 Vesa Karvonen | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
@@ -14,7 +14,6 @@ The above copyright notice and this permission notice shall be included in all | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
{ | ||
"name": "karet", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"description": "Karet is a library that allows you to embed Kefir properties into React VDOM", | ||
@@ -9,8 +9,10 @@ "module": "dist/karet.es.js", | ||
"scripts": { | ||
"dist": "rollup -c", | ||
"dist": "rollup -c && cp dist/karet.js docs/", | ||
"docs": "klipse-github-docs-generator", | ||
"lint": "eslint src test", | ||
"prepare": "concurrently \"npm run lint\" \"npm run dist && npm run test\"", | ||
"prepare": "concurrently \"npm run lint\" \"npm run docs\" \"npm run dist && npm run test\"", | ||
"report-coverage": "nyc report --reporter=lcov > coverage.lcov && codecov", | ||
"test": "nyc mocha && nyc report -r html mocha", | ||
"watch": "concurrently \"npm run watch:dist\" \"npm run watch:test\"", | ||
"watch": "concurrently \"npm run watch:dist\" \"npm run watch:docs\" \"npm run watch:test\"", | ||
"watch:docs": "watch-run -d 100 -i -p '*.md' npm run docs & livereload docs & wait", | ||
"watch:dist": "watch-run -d 100 -i -p 'src/**/*.js' npm run dist", | ||
@@ -39,4 +41,4 @@ "watch:test": "watch-run -d 100 -p 'dist/karet.cjs.js,test/**/*.js' npm run test" | ||
"babel-cli": "^6.26.0", | ||
"babel-eslint": "^8.2.6", | ||
"babel-plugin-annotate-pure-calls": "^0.3.0", | ||
"babel-eslint": "^10.0.1", | ||
"babel-plugin-annotate-pure-calls": "^0.4.0", | ||
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2", | ||
@@ -47,19 +49,21 @@ "babel-preset-es2015": "^6.24.1", | ||
"babel-register": "^6.26.0", | ||
"codecov": "^3.0.4", | ||
"codecov": "^3.1.0", | ||
"concurrently": "^4.0.1", | ||
"eslint": "^5.4.0", | ||
"eslint-plugin-babel": "^5.1.0", | ||
"eslint": "^5.6.1", | ||
"eslint-plugin-babel": "^5.2.1", | ||
"eslint-plugin-react": "^7.11.1", | ||
"kefir": "^3.8.3", | ||
"kefir": "^3.8.5", | ||
"klipse-github-docs-generator": "^0.3.7", | ||
"livereload": "^0.7.0", | ||
"mocha": "^5.2.0", | ||
"nyc": "^12.0.2", | ||
"react": "^16.4.2", | ||
"nyc": "^13.0.1", | ||
"react": "^16.8.0", | ||
"react-addons-test-utils": "^15.6.2", | ||
"react-dom": "^16.4.2", | ||
"rollup": "^0.65.0", | ||
"react-dom": "^16.8.0", | ||
"rollup": "^0.66.4", | ||
"rollup-plugin-babel": "^3.0.7", | ||
"rollup-plugin-commonjs": "^9.1.6", | ||
"rollup-plugin-node-resolve": "^3.3.0", | ||
"rollup-plugin-replace": "^2.0.0", | ||
"rollup-plugin-uglify": "^4.0.0", | ||
"rollup-plugin-commonjs": "^9.1.8", | ||
"rollup-plugin-node-resolve": "^3.4.0", | ||
"rollup-plugin-replace": "^2.1.0", | ||
"rollup-plugin-uglify": "^6.0.0", | ||
"watch-run": "^1.2.5" | ||
@@ -73,4 +77,4 @@ }, | ||
"kefir": "^3.7.0", | ||
"react": "^16.3.1" | ||
"react": "^16.8.0" | ||
} | ||
} |
132
README.md
@@ -1,21 +0,21 @@ | ||
# <a id="karet"></a> [≡](#contents) Karet · [![Gitter](https://img.shields.io/gitter/room/calmm-js/chat.js.svg)](https://gitter.im/calmm-js/chat) [![GitHub stars](https://img.shields.io/github/stars/calmm-js/karet.svg?style=social)](https://github.com/calmm-js/karet) [![npm](https://img.shields.io/npm/dm/karet.svg)](https://www.npmjs.com/package/karet) | ||
# <a id="karet"></a> [≡](#contents) [▶](https://calmm-js.github.io/karet/index.html#karet) [Karet](#karet) · [![Gitter](https://img.shields.io/gitter/room/calmm-js/chat.js.svg)](https://gitter.im/calmm-js/chat) [![GitHub stars](https://img.shields.io/github/stars/calmm-js/karet.svg?style=social)](https://github.com/calmm-js/karet) [![npm](https://img.shields.io/npm/dm/karet.svg)](https://www.npmjs.com/package/karet) | ||
Karet is a library that allows you to embed | ||
[Kefir](https://kefirjs.github.io/kefir/) properties into | ||
[React](https://facebook.github.io/react/) Virtual DOM. Embedding observable | ||
[React](https://facebook.github.io/react/) Virtual DOM. Embedding observable | ||
properties into VDOM has the following benefits: | ||
* It allows you to use only [functional | ||
components](https://facebook.github.io/react/docs/components-and-props.html#functional-and-class-components), | ||
- It allows you to use only | ||
[functional components](https://facebook.github.io/react/docs/components-and-props.html#functional-and-class-components), | ||
because you can then use observables for managing state and component | ||
lifetime, leading to more **_concise code_**. | ||
* It helps you to use React in an **_algorithmically efficient_** way: | ||
* The body of a functional component is evaluated only once each time the | ||
- It helps you to use React in an **_algorithmically efficient_** way: | ||
- The body of a functional component is evaluated only once each time the | ||
component is mounted. | ||
* Only elements that contain embedded properties are rerendered when changes | ||
are pushed through observables. An update to a deeply nested VDOM element | ||
- Only elements that contain embedded properties are rerendered when changes | ||
are pushed through observables. An update to a deeply nested VDOM element | ||
can be an `O(1)` operation. | ||
Using Karet couldn't be simpler. Usually you just `import * as React from | ||
'karet'` and you are good to go. | ||
Using Karet couldn't be simpler. Usually you just | ||
`import * as React from 'karet'` and you are good to go. | ||
@@ -29,12 +29,12 @@ [![npm version](https://badge.fury.io/js/karet.svg)](http://badge.fury.io/js/karet) | ||
## <a id="contents"></a> [≡](#contents) Contents | ||
## <a id="contents"></a> [≡](#contents) [▶](https://calmm-js.github.io/karet/index.html#contents) [Contents](#contents) | ||
* [Tutorial](#tutorial) | ||
* [Reference](#reference) | ||
* [React exports passed through](#react-exports-passed-through) | ||
* [`karet-lift` attribute](#karet-lift) | ||
* [`fromClass(Component)`](#fromClass "fromClass: Component props -> Component (Property props)") | ||
* [Known gotchas](#known-gotchas) | ||
- [Tutorial](#tutorial) | ||
- [Reference](#reference) | ||
- [React exports passed through](#react-exports-passed-through) | ||
- [`karet-lift` attribute](#karet-lift) | ||
- [`fromClass(Component)`](#fromClass 'fromClass: Component props -> Component (Property props)') | ||
- [Known gotchas](#known-gotchas) | ||
## <a id="tutorial"></a> [≡](#contents) Tutorial | ||
## <a id="tutorial"></a> [≡](#contents) [▶](https://calmm-js.github.io/karet/index.html#tutorial) [Tutorial](#tutorial) | ||
@@ -61,7 +61,7 @@ To use Karet, you simply import it as `React`: | ||
with VDOM that can have embedded [Kefir](https://kefirjs.github.io/kefir/) | ||
properties. This works because Karet exports an enhanced version of | ||
properties. This works because Karet exports an enhanced version of | ||
`createElement`. | ||
Note that the result, like the date and time display above, is *just* a React | ||
component. If you export it, you can use it just like any other React component | ||
Note that the result, like the date and time display above, is _just_ a React | ||
component. If you export it, you can use it just like any other React component | ||
and even in modules that do not import `karet`. | ||
@@ -71,39 +71,40 @@ | ||
[More links to live examples in the Calmm documentation | ||
Wiki](https://github.com/calmm-js/documentation/wiki/Links-to-live-examples). | ||
[More links to live examples in the Calmm documentation Wiki](https://github.com/calmm-js/documentation/wiki/Links-to-live-examples). | ||
## <a id="reference"></a> [≡](#contents) Reference | ||
## <a id="reference"></a> [≡](#contents) [▶](https://calmm-js.github.io/karet/index.html#reference) [Reference](#reference) | ||
### <a id="react-exports-passed-through"></a> [≡](#contents) [React exports passed through](#react-exports-passed-through) | ||
### <a id="react-exports-passed-through"></a> [≡](#contents) [▶](https://calmm-js.github.io/karet/index.html#react-exports-passed-through) [React exports passed through](#react-exports-passed-through) | ||
Karet passes through the following exports from React: | ||
* [`Children`](https://reactjs.org/docs/react-api.html#reactchildren) as is. | ||
- [`Children`](https://reactjs.org/docs/react-api.html#reactchildren) as is. | ||
Note that with observable properties in children these functions may not do | ||
exactly what you want and you might want to | ||
[lift](https://github.com/calmm-js/karet.util#lifting) them. | ||
* [`Fragment`](https://reactjs.org/docs/fragments.html) as is. It should work | ||
- [`Fragment`](https://reactjs.org/docs/fragments.html) as is. It should work | ||
without problems. | ||
* [`createContext`](https://reactjs.org/docs/context.html#reactcreatecontext) as | ||
is. Note that with Karet it is preferable to put observable properties into | ||
- [`createContext`](https://reactjs.org/docs/context.html#reactcreatecontext) as | ||
is. Note that with Karet it is preferable to put observable properties into | ||
the context and let changes propagate through them rather than update the | ||
context. Also note that neither the provider nor the consumer are lifted by | ||
default. Lifting the consumer will likely cause no issues, but lifting the | ||
context. Also note that neither the provider nor the consumer are lifted by | ||
default. Lifting the consumer will likely cause no issues, but lifting the | ||
provider would eliminate observables from the `value` property and could cause | ||
problems. If you need to have observable children inside the provider, you | ||
can wrap the children inside a | ||
[`Fragment`](https://reactjs.org/docs/fragments.html). See the CodeSandbox | ||
problems. If you need to have observable children inside the provider, you can | ||
wrap the children inside a | ||
[`Fragment`](https://reactjs.org/docs/fragments.html). See the CodeSandbox | ||
examples | ||
* [Exam Events Form](https://codesandbox.io/s/x20w218owo) where the context is | ||
- [Exam Events Form](https://codesandbox.io/s/x20w218owo) where the context is | ||
used to transmit the language as an observable atom, and | ||
* [Form using Context](https://codesandbox.io/s/2rq54pgrp) where context is | ||
- [Form using Context](https://codesandbox.io/s/2rq54pgrp) where context is | ||
used to transmit form properties to form elements. | ||
* [`createElement`](https://reactjs.org/docs/react-api.html#createelement) which | ||
- [`createElement`](https://reactjs.org/docs/react-api.html#createelement) which | ||
lifts Kefir properties in [fragments](https://reactjs.org/docs/fragments.html) | ||
and built-in HTML elements. | ||
* [`forwardRef`](https://reactjs.org/docs/react-api.html#reactforwardref) as is. | ||
- [`forwardRef`](https://reactjs.org/docs/react-api.html#reactforwardref) as is. | ||
- [`useContext`](https://reactjs.org/docs/hooks-reference.html#usecontext) as | ||
is. | ||
Notably the following are not exported: | ||
* [`Component`](https://reactjs.org/docs/react-api.html#reactcomponent) and | ||
- [`Component`](https://reactjs.org/docs/react-api.html#reactcomponent) and | ||
[`PureComponent`](https://reactjs.org/docs/react-api.html#reactpurecomponent), | ||
@@ -113,16 +114,25 @@ because with Karet you really don't need them and the `render` method can | ||
embedded into VDOM. | ||
* [`cloneElement`](https://reactjs.org/docs/react-api.html#cloneelement) does | ||
not work out of the box with elements containing Kefir properties. It should | ||
- [`cloneElement`](https://reactjs.org/docs/react-api.html#cloneelement) does | ||
not work out of the box with elements containing Kefir properties. It should | ||
be possible [to support it](https://github.com/calmm-js/karet/issues/6), | ||
however. | ||
* [`createRef`](https://reactjs.org/docs/react-api.html#reactcreateref) is not | ||
- [`createRef`](https://reactjs.org/docs/react-api.html#reactcreateref) is not | ||
exported, because [Karet Util](https://github.com/calmm-js/karet.util) | ||
provides an [alternative](https://github.com/calmm-js/karet.util/#U-refTo) | ||
that works better with observable properties. | ||
- [`Suspense` and `lazy`](https://reactjs.org/docs/react-api.html#reactsuspense) | ||
are not needed since `import()` returns a promise and you can just convert | ||
that to an observable property | ||
[like this](https://codesandbox.io/s/n5mvx6v69m). | ||
- [Most React hooks](https://reactjs.org/docs/hooks-reference.html) are not | ||
exported because they are not typically needed in Karet components. State | ||
should be handled in [atoms](https://github.com/calmm-js/kefir.atom). Effects | ||
can already be handled using observable properties as children or props. | ||
### <a id="karet-lift"></a> [≡](#contents) [`karet-lift` attribute](#karet-lift) | ||
### <a id="karet-lift"></a> [≡](#contents) [▶](https://calmm-js.github.io/karet/index.html#karet-lift) [`karet-lift` attribute](#karet-lift) | ||
Karet only lifts built-in HTML elements and [fragments](#Fragment) implicitly. | ||
The `karet-lift` attribute on a non-primitive element instructs Karet to lift | ||
the element. | ||
Karet only lifts built-in HTML elements and | ||
[fragments](https://reactjs.org/docs/fragments.html) implicitly. The | ||
`karet-lift` attribute on a non-primitive element instructs Karet to lift the | ||
element. | ||
@@ -148,12 +158,13 @@ For example, you could write: | ||
to be able to use `Select` from [React | ||
Select](https://github.com/JedWatson/react-select) with embedded [Kefir | ||
Atoms](https://github.com/calmm-js/kefir.atom). | ||
to be able to use `Select` from | ||
[React Select](https://github.com/JedWatson/react-select) with embedded | ||
[Kefir Atoms](https://github.com/calmm-js/kefir.atom). | ||
[Here is a live example in CodeSandbox](https://codesandbox.io/s/7yjj16jz7q). | ||
### <a id="fromClass"></a> [≡](#contents) [`fromClass(Component)`](#fromClass "fromClass: Component props -> Component (Property props)") | ||
### <a id="fromClass"></a> [≡](#contents) [▶](https://calmm-js.github.io/karet/index.html#fromClass) [`fromClass(Component)`](#fromClass 'fromClass: Component props -> Component (Property props)') | ||
Karet only lifts built-in HTML elements and [fragments](#Fragment) implicitly. | ||
`fromClass` allows one to create lifted version of a given React component. | ||
Karet only lifts built-in HTML elements and | ||
[fragments](https://reactjs.org/docs/fragments.html) implicitly. `fromClass` | ||
allows one to create lifted version of a given React component. | ||
@@ -178,15 +189,14 @@ For example, you could write: | ||
to be able to use `Select` from [React | ||
Select](https://github.com/JedWatson/react-select) with embedded [Kefir | ||
Atoms](https://github.com/calmm-js/kefir.atom). | ||
to be able to use `Select` from | ||
[React Select](https://github.com/JedWatson/react-select) with embedded | ||
[Kefir Atoms](https://github.com/calmm-js/kefir.atom). | ||
[Here is a live example in CodeSandbox](https://codesandbox.io/s/7yjj16jz7q). | ||
### <a id="known-gotchas"></a> [≡](#contents) [Known gotchas](#known-gotchas) | ||
### <a id="known-gotchas"></a> [≡](#contents) [▶](https://calmm-js.github.io/karet/index.html#known-gotchas) [Known gotchas](#known-gotchas) | ||
The [React inline elements transform | ||
](https://babeljs.io/docs/plugins/transform-react-inline-elements/) is | ||
incompatible with Karet, because it bypasses `React.createElement`. OTOH, the | ||
[React constant elements | ||
transform](https://babeljs.io/docs/plugins/transform-react-constant-elements/) | ||
The | ||
[React inline elements transform ](https://babeljs.io/docs/plugins/transform-react-inline-elements/) | ||
is incompatible with Karet, because it bypasses `React.createElement`. OTOH, the | ||
[React constant elements transform](https://babeljs.io/docs/plugins/transform-react-constant-elements/) | ||
works just fine with Karet. |
@@ -138,2 +138,2 @@ import * as I from 'infestines' | ||
export {Children, Fragment, createContext, forwardRef} from 'react' | ||
export {Children, Fragment, createContext, forwardRef, useContext} from 'react' |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32300
197
28
9
501
1