Add reagent.core dom functions back but deprecated

This commit is contained in:
Juho Teperi 2020-03-06 13:46:46 +02:00
parent a027928f19
commit a8c401859d
3 changed files with 55 additions and 9 deletions

View File

@ -1,15 +1,18 @@
# Changelog
## Next
## 0.10.0-alpha
- Removed deprecated namespaces/function/macros:
- Removed `reagent.interop` namespace (macros `$`, `$!`, `unchecked-aget` and `unchecked-aset`)
- `reagent.core/component-path` (Reason: implementation depends on internal React
details and using just Component `displayName` achieves nearly the same)
- All DOM related functions (notably `render` and `dom-node`) have been removed
from `reagent.core` namespace and are now only available in `reagent.dom` namespace.
Main feature of this release is to deprecate functions that are going to be
removed in the future releases, to make transition easier.
- All DOM related functions (notably `render` and `dom-node`) are now deprecated in
`reagent.core` namespace and versions in `reagent.dom` namespace should be used
instead. These will be removed in the next version.
This is to make non-DOM environments (React-native) first class targets with Reagent,
as requiring `react-dom` always causes problems in such environments.
- Removed deprecated `reagent.interop` namespace (macros `$`, `$!`, `unchecked-aget` and `unchecked-aset`)
- Removed `reagent.core/component-path`. The implementation depended on internal React
details and using just Component `displayName` achieves nearly the same.
- `Error rendering component` messages no longer contain component stack information.
Instead one should use [an Error Boundary](https://reactjs.org/docs/error-boundaries.html#component-stack-traces)
to catch the problem and look at the error information `componentStack` property.

View File

@ -1,4 +1,4 @@
(defproject reagent "1.0.0-SNAPSHOT"
(defproject reagent "0.10.0-SNAPSHOT"
:url "http://github.com/reagent-project/reagent"
:license {:name "MIT"}
:description "A simple ClojureScript interface to React"

View File

@ -9,7 +9,8 @@
[reagent.ratom :as ratom]
[reagent.debug :as deb :refer-macros [assert-some assert-component
assert-js-object assert-new-state
assert-callable]]))
assert-callable]]
[reagent.dom :as dom]))
(def is-client util/is-client)
@ -63,6 +64,42 @@
(assert-some c "Component")
(comp/reactify-component c))
(defn render
"Render a Reagent component into the DOM. The first argument may be
either a vector (using Reagent's Hiccup syntax), or a React element.
The second argument should be a DOM node.
Optionally takes a callback that is called when the component is in place.
Returns the mounted component instance."
{:deprecated "0.10.0"}
([comp container]
(dom/render comp container))
([comp container callback]
(dom/render comp container callback)))
(defn unmount-component-at-node
"Remove a component from the given DOM node."
{:deprecated "0.10.0"}
[container]
(dom/unmount-component-at-node container))
(defn force-update-all
"Force re-rendering of all mounted Reagent components. This is
probably only useful in a development environment, when you want to
update components in response to some dynamic changes to code.
Note that force-update-all may not update root components. This
happens if a component 'foo' is mounted with `(render [foo])` (since
functions are passed by value, and not by reference, in
ClojureScript). To get around this you'll have to introduce a layer
of indirection, for example by using `(render [#'foo])` instead."
{:deprecated "0.10.0"}
[]
(ratom/flush!)
(dom/force-update-all)
(batch/flush-after-render))
(defn create-class
"Creates JS class based on provided Clojure map, for example:
@ -172,6 +209,12 @@
(assert-component this)
(comp/get-argv this))
(defn dom-node
"Returns the root DOM node of a mounted component."
{:deprecated "0.10.0"}
[this]
(dom/dom-node this))
(defn class-names
"Function which normalizes and combines class values to a string