diff --git a/package.json b/package.json index 14affa1..caf742a 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,16 @@ { - "dependencies": { - "react": "^15.2.1", - "react-dom": "^15.2.1" - }, - "scripts": { - "bundle": "webpack && NODE_ENV=production webpack -p" - }, - "devDependencies": { - "babel-core": "^5.8.25", - "webpack": "^1.12.2" - } + "dependencies": { + "browser-resolve": "^1.11.2", + "create-react-class": "^15.5.3", + "react": "^15.5.3", + "react-dom": "^15.5.3", + "resolve": "^1.3.3" + }, + "scripts": { + "bundle": "webpack && NODE_ENV=production webpack -p" + }, + "devDependencies": { + "babel-core": "^5.8.25", + "webpack": "^1.12.2" + } } diff --git a/project.clj b/project.clj index ad2e564..1aada7c 100644 --- a/project.clj +++ b/project.clj @@ -4,10 +4,11 @@ :description "A simple ClojureScript interface to React" :dependencies [[org.clojure/clojure "1.8.0"] - [org.clojure/clojurescript "1.8.51"] - [cljsjs/react-dom "15.5.4-0"] - [cljsjs/react-dom-server "15.5.4-0"] - [cljsjs/create-react-class "15.5.3-0"]] + [org.clojure/clojurescript "1.9.562"] + ; [cljsjs/react-dom "15.5.4-0"] + ; [cljsjs/react-dom-server "15.5.4-0"] + ; [cljsjs/create-react-class "15.5.3-0"] + ] :plugins [[lein-cljsbuild "1.1.6"] [lein-codox "0.10.3"]] @@ -37,7 +38,441 @@ :optimizations :none ;; :recompile-dependents false :output-dir "outsite/public/js/out" - :asset-path "js/out"}}}}}] + :asset-path "js/out" + :language-in :ecmascript6 + :closure-warnings {:non-standard-jsdoc :off} + ;; From node-inputs, with file requiring react, react-dom, react-dom/server, create-react-class + :foreign-libs [{:file "node_modules/create-react-class/index.js" + :module-type :commonjs + :provides ["create-react-class"]} + {:file "node_modules/react/react.js" + :module-type :commonjs + :provides ["react"]} + {:file "node_modules/react-dom/index.js" + :module-type :commonjs + :provides ["react-dom"]} + {:file "node_modules/react-dom/server.js" + :module-type :commonjs + ;; Added manually + :provides ["react-dom.server"]} + {:file "node_modules/react/lib/React.js" + :module-type :commonjs} + {:file "node_modules/create-react-class/factory.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDOM.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDOMServer.js" + :module-type :commonjs} + {:file "node_modules/react/lib/ReactChildren.js" + :module-type :commonjs} + {:file "node_modules/react/lib/ReactPureComponent.js" + :module-type :commonjs} + {:file "node_modules/react/lib/ReactComponent.js" + :module-type :commonjs} + {:file "node_modules/react/lib/ReactClass.js" + :module-type :commonjs} + {:file "node_modules/react/lib/ReactDOMFactories.js" + :module-type :commonjs} + {:file "node_modules/react/lib/ReactElement.js" + :module-type :commonjs} + {:file "node_modules/react/lib/ReactPropTypes.js" + :module-type :commonjs} + {:file "node_modules/react/lib/ReactVersion.js" + :module-type :commonjs} + {:file "node_modules/react/lib/onlyChild.js" + :module-type :commonjs} + {:file "node_modules/react/lib/canDefineProperty.js" + :module-type :commonjs} + {:file "node_modules/react/lib/ReactElementValidator.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDOMComponentTree.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDefaultInjection.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactMount.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactReconciler.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactUpdates.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactVersion.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/findDOMNode.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/getHostComponentFromComposite.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/renderSubtreeIntoContainer.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactInstrumentation.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDOMUnknownPropertyHook.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDOMNullInputValuePropHook.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDOMInvalidARIAHook.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactServerRendering.js" + :module-type :commonjs} + {:file "node_modules/create-react-class/node_modules/fbjs/lib/emptyObject.js" + :module-type :commonjs} + {:file "node_modules/create-react-class/node_modules/fbjs/lib/invariant.js" + :module-type :commonjs} + {:file "node_modules/create-react-class/node_modules/fbjs/lib/warning.js" + :module-type :commonjs} + {:file "node_modules/create-react-class/node_modules/object-assign/index.js" + :module-type :commonjs} + {:file "node_modules/react/lib/PooledClass.js" + :module-type :commonjs} + {:file "node_modules/react/lib/traverseAllChildren.js" + :module-type :commonjs} + {:file "node_modules/react/lib/ReactNoopUpdateQueue.js" + :module-type :commonjs} + {:file "node_modules/react/lib/reactProdInvariant.js" + :module-type :commonjs} + {:file "node_modules/react/lib/ReactPropTypeLocationNames.js" + :module-type :commonjs} + {:file "node_modules/react/lib/ReactCurrentOwner.js" + :module-type :commonjs} + {:file "node_modules/react/lib/ReactElementSymbol.js" + :module-type :commonjs} + {:file "node_modules/react/lib/ReactComponentTreeHook.js" + :module-type :commonjs} + {:file "node_modules/react/lib/checkReactTypeSpec.js" + :module-type :commonjs} + {:file "node_modules/react/lib/getIteratorFn.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/reactProdInvariant.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/DOMProperty.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDOMComponentFlags.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/DOMLazyTree.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactBrowserEventEmitter.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDOMContainerInfo.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDOMFeatureFlags.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactFeatureFlags.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactInstanceMap.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactMarkupChecksum.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactUpdateQueue.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/instantiateReactComponent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/setInnerHTML.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/shouldUpdateReactComponent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactRef.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/CallbackQueue.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/PooledClass.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/Transaction.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ARIADOMPropertyConfig.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/BeforeInputEventPlugin.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ChangeEventPlugin.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/DefaultEventPluginOrder.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/EnterLeaveEventPlugin.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/HTMLDOMPropertyConfig.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactComponentBrowserEnvironment.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDOMComponent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDOMTreeTraversal.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDOMTextComponent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDOMEmptyComponent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactEventListener.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDefaultBatchingStrategy.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactInjection.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactReconcileTransaction.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/SVGDOMPropertyConfig.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/SelectEventPlugin.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/SimpleEventPlugin.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDebugTool.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/EventPluginRegistry.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactNodeTypes.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactServerBatchingStrategy.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactServerRenderingTransaction.js" + :module-type :commonjs} + {:file "node_modules/react/node_modules/object-assign/index.js" + :module-type :commonjs} + {:file "node_modules/create-react-class/node_modules/fbjs/lib/emptyFunction.js" + :module-type :commonjs} + {:file "node_modules/react/lib/KeyEscapeUtils.js" + :module-type :commonjs} + {:file "node_modules/react/lib/ReactPropTypesSecret.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/DOMNamespaces.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/createMicrosoftUnsafeLocalFunction.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/setTextContent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactEventEmitterMixin.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ViewportMetrics.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/getVendorPrefixedEventName.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/isEventSupported.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/validateDOMNesting.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/adler32.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactCompositeComponent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactEmptyComponent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactHostComponent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactOwner.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/EventPropagators.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/FallbackCompositionState.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/SyntheticInputEvent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/EventPluginHub.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/SyntheticCompositionEvent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/SyntheticEvent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/getEventTarget.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/isTextInputElement.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/SyntheticMouseEvent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/DOMChildrenOperations.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDOMIDOperations.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/AutoFocusUtils.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/CSSPropertyOperations.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/DOMPropertyOperations.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDOMInput.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDOMOption.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDOMSelect.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDOMTextarea.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactMultiChild.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/escapeTextContentForBrowser.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/EventPluginUtils.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactComponentEnvironment.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactInputSelection.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/SyntheticAnimationEvent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/SyntheticClipboardEvent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/SyntheticFocusEvent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/SyntheticKeyboardEvent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/SyntheticDragEvent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/SyntheticTouchEvent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/SyntheticTransitionEvent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/SyntheticUIEvent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/SyntheticWheelEvent.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/getEventCharCode.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactInvalidSetStateWarningHook.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactHostOperationHistoryHook.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactServerUpdateQueue.js" + :module-type :commonjs} + {:file "node_modules/react/node_modules/fbjs/lib/warning.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/ExecutionEnvironment.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/warning.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/object-assign/index.js" + :module-type :commonjs} + {:file "node_modules/react/node_modules/prop-types/factory.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactErrorUtils.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/checkReactTypeSpec.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/accumulateInto.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/forEachAccumulated.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/getTextContentAccessor.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/getEventModifierState.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/Danger.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/CSSProperty.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/dangerousStyleValue.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/quoteAttributeValueForBrowser.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/LinkedValueUtils.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactChildReconciler.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/flattenChildren.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactDOMSelection.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/getEventKey.js" + :module-type :commonjs} + {:file "node_modules/react/node_modules/fbjs/lib/emptyFunction.js" + :module-type :commonjs} + {:file "node_modules/react/node_modules/fbjs/lib/emptyObject.js" + :module-type :commonjs} + {:file "node_modules/react/node_modules/fbjs/lib/invariant.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/invariant.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/emptyObject.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/emptyFunction.js" + :module-type :commonjs} + {:file "node_modules/react/node_modules/prop-types/factoryWithTypeCheckers.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactPropTypeLocationNames.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactPropTypesSecret.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/KeyEscapeUtils.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/traverseAllChildren.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/getNodeForCharacterOffset.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/shallowEqual.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/EventListener.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/getUnboundedScrollPosition.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/getActiveElement.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/performanceNow.js" + :module-type :commonjs} + {:file "node_modules/react/node_modules/prop-types/lib/ReactPropTypesSecret.js" + :module-type :commonjs} + {:file "node_modules/react/node_modules/prop-types/checkPropTypes.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/ReactElementSymbol.js" + :module-type :commonjs} + {:file "node_modules/react-dom/lib/getIteratorFn.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/focusNode.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/camelizeStyleName.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/hyphenateStyleName.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/memoizeStringOnly.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/containsNode.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/performance.js" + :module-type :commonjs} + {:file "node_modules/react/lib/getNextDebugID.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/prop-types/factory.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/createNodesFromMarkup.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/camelize.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/hyphenate.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/isTextNode.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/prop-types/factoryWithTypeCheckers.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/createArrayFromMixed.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/getMarkupWrap.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/lib/isNode.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/prop-types/lib/ReactPropTypesSecret.js" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/prop-types/checkPropTypes.js" + :module-type :commonjs} + {:file "node_modules/create-react-class/package.json" + :module-type :commonjs} + {:file "node_modules/react/package.json" + :module-type :commonjs} + {:file "node_modules/react-dom/package.json" + :module-type :commonjs} + {:file "node_modules/create-react-class/node_modules/fbjs/package.json" + :module-type :commonjs} + {:file "node_modules/create-react-class/node_modules/object-assign/package.json" + :module-type :commonjs} + {:file "node_modules/react/node_modules/object-assign/package.json" + :module-type :commonjs} + {:file "node_modules/react/node_modules/fbjs/package.json" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/fbjs/package.json" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/object-assign/package.json" + :module-type :commonjs} + {:file "node_modules/react/node_modules/prop-types/package.json" + :module-type :commonjs} + {:file "node_modules/react-dom/node_modules/prop-types/package.json" + :module-type :commonjs}] + ; :npm-deps {:react "15.5.3" + ; :react-dom "15.5.3" + ; :create-react-class "15.5.3"} + }}}}}] :site {:resource-paths ^:replace ["outsite"] :figwheel {:css-dirs ^:replace ["outsite/public/css"]}} diff --git a/site/public/index.html b/site/public/index.html index 3137238..0beb8a8 100644 --- a/site/public/index.html +++ b/site/public/index.html @@ -12,6 +12,7 @@ diff --git a/src/reagent/core.cljs b/src/reagent/core.cljs index f3aaec9..c11285d 100644 --- a/src/reagent/core.cljs +++ b/src/reagent/core.cljs @@ -1,7 +1,8 @@ (ns reagent.core (:require-macros [reagent.core]) (:refer-clojure :exclude [partial atom flush]) - (:require [reagent.impl.template :as tmpl] + (:require [react :as react] + [reagent.impl.template :as tmpl] [reagent.impl.component :as comp] [reagent.impl.util :as util] [reagent.impl.batching :as batch] @@ -12,8 +13,6 @@ (def is-client util/is-client) -(def react util/react) - (defn create-element "Create a native React element, by calling React.createElement directly. @@ -31,13 +30,13 @@ (create-element type nil)) ([type props] (assert (not (map? props))) - ($ react createElement type props)) + (react/createElement type props)) ([type props child] (assert (not (map? props))) - ($ react createElement type props child)) + (react/createElement type props child)) ([type props child & children] (assert (not (map? props))) - (apply ($ react :createElement) type props child children))) + (apply react/createElement type props child children))) (defn as-element "Turns a vector of Hiccup syntax into a React element. Returns form diff --git a/src/reagent/dom.cljs b/src/reagent/dom.cljs index 129b859..d676e3e 100644 --- a/src/reagent/dom.cljs +++ b/src/reagent/dom.cljs @@ -1,5 +1,5 @@ (ns reagent.dom - (:require [cljsjs.react.dom] + (:require [react-dom] [reagent.impl.util :as util] [reagent.impl.template :as tmpl] [reagent.impl.batching :as batch] @@ -9,31 +9,21 @@ (defonce ^:private imported nil) -(defn module [] - (cond - (some? imported) imported - (exists? js/ReactDOM) (set! imported js/ReactDOM) - (exists? js/require) (or (set! imported (js/require "react-dom")) - (throw (js/Error. "require('react-dom') failed"))) - :else - (throw (js/Error. "js/ReactDOM is missing")))) - - (defonce ^:private roots (atom {})) (defn- unmount-comp [container] (swap! roots dissoc container) - ($ (module) unmountComponentAtNode container)) + (react-dom/unmountComponentAtNode container)) (defn- render-comp [comp container callback] (binding [util/*always-update* true] - (->> ($ (module) render (comp) container - (fn [] - (binding [util/*always-update* false] - (swap! roots assoc container [comp container]) - (batch/flush-after-render) - (if (some? callback) - (callback)))))))) + (react-dom/render (comp) container + (fn [] + (binding [util/*always-update* false] + (swap! roots assoc container [comp container]) + (batch/flush-after-render) + (if (some? callback) + (callback))))))) (defn- re-render-component [comp container] (render-comp comp container nil)) @@ -59,7 +49,7 @@ (defn dom-node "Returns the root DOM node of a mounted component." [this] - ($ (module) findDOMNode this)) + (react-dom/findDOMNode this)) (set! tmpl/find-dom-node dom-node) diff --git a/src/reagent/dom/server.cljs b/src/reagent/dom/server.cljs index 4e3bd1f..5d9d1bd 100644 --- a/src/reagent/dom/server.cljs +++ b/src/reagent/dom/server.cljs @@ -1,5 +1,5 @@ (ns reagent.dom.server - (:require [cljsjs.react.dom.server] + (:require [react-dom.server :as dom-server] [reagent.impl.util :as util] [reagent.impl.template :as tmpl] [reagent.ratom :as ratom] @@ -7,27 +7,16 @@ (defonce ^:private imported nil) -(defn module [] - (cond - (some? imported) imported - (exists? js/ReactDOMServer) (set! imported js/ReactDOMServer) - (exists? js/require) (or (set! imported (js/require "react-dom/server")) - (throw (js/Error. - "require('react-dom/server') failed"))) - :else - (throw (js/Error. "js/ReactDOMServer is missing")))) - - (defn render-to-string "Turns a component into an HTML string." [component] (ratom/flush!) (binding [util/*non-reactive* true] - ($ (module) renderToString (tmpl/as-element component)))) + (dom-server/renderToString (tmpl/as-element component)))) (defn render-to-static-markup "Turns a component into an HTML string, without data-react-id attributes, etc." [component] (ratom/flush!) (binding [util/*non-reactive* true] - ($ (module) renderToStaticMarkup (tmpl/as-element component)))) + (dom-server/renderToStaticMarkup (tmpl/as-element component)))) diff --git a/src/reagent/impl/component.cljs b/src/reagent/impl/component.cljs index 58d2b68..3d913f6 100644 --- a/src/reagent/impl/component.cljs +++ b/src/reagent/impl/component.cljs @@ -1,5 +1,7 @@ (ns reagent.impl.component - (:require [reagent.impl.util :as util] + (:require [create-react-class] + [react :as react] + [reagent.impl.util :as util] [reagent.impl.batching :as batch] [reagent.ratom :as ratom] [reagent.interop :refer-macros [$ $!]] @@ -48,7 +50,7 @@ (if-some [v ($ p :argv)] (extract-children v) (->> ($ p :children) - ($ util/react Children.toArray) + (react/Children.toArray) (into []))))) (defn ^boolean reagent-class? [c] @@ -264,7 +266,7 @@ {:pre [(map? body)]} (->> body cljsify - util/create-class)) + create-react-class)) (defn component-path [c] (let [elem (some-> (or (some-> c ($ :_reactInternalInstance)) diff --git a/src/reagent/impl/template.cljs b/src/reagent/impl/template.cljs index 34d8bc5..97b9108 100644 --- a/src/reagent/impl/template.cljs +++ b/src/reagent/impl/template.cljs @@ -1,5 +1,6 @@ (ns reagent.impl.template - (:require [clojure.string :as string] + (:require [react :as react] + [clojure.string :as string] [clojure.walk :refer [prewalk]] [reagent.impl.util :as util :refer [is-client]] [reagent.impl.component :as comp] @@ -251,7 +252,7 @@ jsprops #js{:argv v}] (when-some [key (key-from-vec v)] ($! jsprops :key key)) - ($ util/react createElement c jsprops))) + (react/createElement c jsprops))) (defn adapt-react-class [c] (doto (->NativeWrapper) @@ -392,12 +393,12 @@ (defn make-element [argv comp jsprops first-child] (case (- (count argv) first-child) ;; Optimize cases of zero or one child - 0 ($ util/react createElement comp jsprops) + 0 (react/createElement comp jsprops) - 1 ($ util/react createElement comp jsprops + 1 (react/createElement comp jsprops (as-element (nth argv first-child nil))) - (.apply ($ util/react :createElement) nil + (.apply react/createElement nil (reduce-kv (fn [a k v] (when (>= k first-child) (.push a (as-element v))) diff --git a/src/reagent/impl/util.cljs b/src/reagent/impl/util.cljs index 5e82e27..6a9e99b 100644 --- a/src/reagent/impl/util.cljs +++ b/src/reagent/impl/util.cljs @@ -1,22 +1,9 @@ (ns reagent.impl.util - (:require [cljsjs.react] - [cljsjs.create-react-class] + (:require [create-react-class :as create-react-class] [reagent.debug :refer-macros [dbg log warn]] [reagent.interop :refer-macros [$ $!]] [clojure.string :as string])) -(defonce react - (cond (exists? js/React) js/React - (exists? js/require) (or (js/require "react") - (throw (js/Error. "require('react') failed"))) - :else (throw (js/Error. "js/React is missing")))) - -(defonce create-class - (cond (exists? js/createReactClass) js/createReactClass - (exists? js/require) (or (js/require "create-react-class") - (throw (js/Error. "require('create-react-class') failed"))) - :else (throw (js/Error. "js/createReactClass is missing")))) - (def is-client (and (exists? js/window) (-> js/window ($ :document) nil? not))) diff --git a/test/reagenttest/testreagent.cljs b/test/reagenttest/testreagent.cljs index 0e06f29..7e2b8bd 100644 --- a/test/reagenttest/testreagent.cljs +++ b/test/reagenttest/testreagent.cljs @@ -1,5 +1,6 @@ (ns reagenttest.testreagent (:require [cljs.test :as t :refer-macros [is deftest testing]] + [create-react-class] [reagent.ratom :as rv :refer-macros [reaction]] [reagent.debug :as debug :refer-macros [dbg println log dev?]] [reagent.interop :refer-macros [$ $!]] @@ -459,7 +460,7 @@ (is (= (rstr (ae [:div [:div "foo"]])) (rstr (ae [:div (ce "div" nil "foo")])))))) -(def ndiv (util/create-class +(def ndiv (create-react-class #js {:displayName "ndiv" :render (fn [] @@ -923,7 +924,7 @@ comp4 (fn comp4 [] (for [i (range 0 1)] [:p "foo"])) - nat (util/create-class #js {:render (fn [])}) + nat (create-react-class #js {:render (fn [])}) pkg "reagenttest.testreagent." stack1 (str "in " pkg "comp1") stack2 (str "in " pkg "comp2 > " pkg "comp1")