1- /* global exports */
2- "use strict" ;
3-
4- var React = require ( "react" ) ;
1+ import React from "react" ;
52
63function createClass ( baseClass ) {
74 function bindProperty ( instance , prop , value ) {
85 switch ( prop ) {
9- case ' state' :
10- case ' render' :
11- case ' componentDidMount' :
12- case ' componentWillUnmount' :
6+ case " state" :
7+ case " render" :
8+ case " componentDidMount" :
9+ case " componentWillUnmount" :
1310 instance [ prop ] = value ;
1411 break ;
1512
16- case ' componentDidCatch' :
17- case ' componentWillUpdate' :
18- case ' shouldComponentUpdate' :
19- case ' getSnapshotBeforeUpdate' :
13+ case " componentDidCatch" :
14+ case " componentWillUpdate" :
15+ case " shouldComponentUpdate" :
16+ case " getSnapshotBeforeUpdate" :
2017 instance [ prop ] = function ( a , b ) { return value ( a ) ( b ) ( ) ; } ;
2118 break ;
2219
23- case ' componentDidUpdate' :
20+ case " componentDidUpdate" :
2421 instance [ prop ] = function ( a , b , c ) { return value ( a ) ( b ) ( c ) ( ) ; } ;
2522 break ;
2623
27- case ' unsafeComponentWillMount' :
28- instance [ ' UNSAFE_componentWillMount' ] = value ;
24+ case " unsafeComponentWillMount" :
25+ instance [ " UNSAFE_componentWillMount" ] = value ;
2926 break ;
3027
31- case ' unsafeComponentWillReceiveProps' :
32- instance [ ' UNSAFE_componentWillReceiveProps' ] = function ( a ) { return value ( a ) ( ) ; } ;
28+ case " unsafeComponentWillReceiveProps" :
29+ instance [ " UNSAFE_componentWillReceiveProps" ] = function ( a ) { return value ( a ) ( ) ; } ;
3330 break ;
3431
35- case ' unsafeComponentWillUpdate' :
36- instance [ ' UNSAFE_componentWillUpdate' ] = function ( a , b ) { return value ( a ) ( b ) ( ) ; } ;
32+ case " unsafeComponentWillUpdate" :
33+ instance [ " UNSAFE_componentWillUpdate" ] = function ( a , b ) { return value ( a ) ( b ) ( ) ; } ;
3734 break ;
3835
3936 default :
40- throw new Error ( ' [purescript-react] Not a component property: ' + prop ) ;
37+ throw new Error ( " [purescript-react] Not a component property: " + prop ) ;
4138 }
4239 }
4340
@@ -46,6 +43,7 @@ function createClass(baseClass) {
4643 var Constructor = function ( props ) {
4744 baseClass . call ( this , props ) ;
4845 var spec = ctrFn ( this ) ( ) ;
46+ // eslint-disable-next-line guard-for-in
4947 for ( var k in spec ) {
5048 bindProperty ( this , k , spec [ k ] ) ;
5149 }
@@ -60,6 +58,10 @@ function createClass(baseClass) {
6058 } ;
6159}
6260
61+ var componentImpl = createClass ( React . Component ) ;
62+ export { componentImpl } ;
63+
64+ // eslint-disable-next-line no-unused-vars
6365function createClassWithDerivedState ( classCtr ) {
6466 return function ( displayName ) {
6567 return function ( getDerivedStateFromProps ) {
@@ -72,28 +74,22 @@ function createClassWithDerivedState(classCtr) {
7274 } ;
7375}
7476
75- var componentImpl = createClass ( React . Component ) ;
76- exports . componentImpl = componentImpl ;
77- exports . componentWithDerivedStateImpl = createClassWithDerivedState ( componentImpl ) ;
77+ export const componentWithDerivedStateImpl = createClassWithDerivedState ( componentImpl ) ;
7878
7979var pureComponentImpl = createClass ( React . PureComponent ) ;
80- exports . pureComponentImpl = pureComponentImpl ;
81- exports . pureComponentWithDerivedStateImpl = createClassWithDerivedState ( pureComponentImpl ) ;
82-
83- exports . statelessComponent = function ( x ) { return x ; } ;
84-
85- exports . fragment = React . Fragment ;
80+ export { pureComponentImpl } ;
81+ export const pureComponentWithDerivedStateImpl = createClassWithDerivedState ( pureComponentImpl ) ;
82+ export function statelessComponent ( x ) { return x ; }
83+ export const fragment = React . Fragment ;
8684
8785function getProps ( this_ ) {
8886 return function ( ) {
8987 return this_ . props ;
9088 } ;
9189}
92- exports . getProps = getProps ;
93-
94- exports . childrenToArray = React . Children . toArray ;
95-
96- exports . childrenCount = React . Children . count ;
90+ export { getProps } ;
91+ export const childrenToArray = React . Children . toArray ;
92+ export const childrenCount = React . Children . count ;
9793
9894function setStateImpl ( this_ ) {
9995 return function ( state ) {
@@ -102,7 +98,7 @@ function setStateImpl(this_) {
10298 } ;
10399 } ;
104100}
105- exports . setStateImpl = setStateImpl ;
101+ export { setStateImpl } ;
106102
107103function setStateWithCallbackImpl ( this_ ) {
108104 return function ( state ) {
@@ -113,17 +109,17 @@ function setStateWithCallbackImpl(this_) {
113109 } ;
114110 } ;
115111}
116- exports . setStateWithCallbackImpl = setStateWithCallbackImpl ;
112+ export { setStateWithCallbackImpl } ;
117113
118114function getState ( this_ ) {
119115 return function ( ) {
120116 if ( ! this_ . state ) {
121- throw new Error ( ' [purescript-react] Cannot get state within constructor' ) ;
117+ throw new Error ( " [purescript-react] Cannot get state within constructor" ) ;
122118 }
123119 return this_ . state ;
124120 } ;
125121}
126- exports . getState = getState ;
122+ export { getState } ;
127123
128124function forceUpdateWithCallback ( this_ ) {
129125 return function ( cb ) {
@@ -132,7 +128,7 @@ function forceUpdateWithCallback(this_) {
132128 } ;
133129 } ;
134130}
135- exports . forceUpdateWithCallback = forceUpdateWithCallback ;
131+ export { forceUpdateWithCallback } ;
136132
137133function createElement ( class_ ) {
138134 return function ( props ) {
@@ -141,25 +137,25 @@ function createElement(class_) {
141137 } ;
142138 } ;
143139}
144- exports . createElementImpl = createElement ;
145- exports . createElementTagName = createElement ;
140+ export { createElement as createElementImpl } ;
141+ export { createElement as createElementTagName } ;
146142
147143function createLeafElement ( class_ ) {
148144 return function ( props ) {
149145 return React . createElement ( class_ , props ) ;
150146 } ;
151147}
152- exports . createLeafElementImpl = createLeafElement ;
148+ export { createLeafElement as createLeafElementImpl } ;
153149
154150function createElementDynamic ( class_ ) {
155151 return function ( props ) {
156152 return function ( children ) {
157153 return React . createElement ( class_ , props , children ) ;
158154 } ;
159155 } ;
160- } ;
161- exports . createElementDynamicImpl = createElementDynamic ;
162- exports . createElementTagNameDynamic = createElementDynamic ;
156+ }
157+ export { createElementDynamic as createElementDynamicImpl } ;
158+ export { createElementDynamic as createElementTagNameDynamic } ;
163159
164160function createContext ( defaultValue ) {
165161 var context = React . createContext ( defaultValue ) ;
@@ -168,4 +164,4 @@ function createContext(defaultValue) {
168164 provider : context . Provider
169165 } ;
170166}
171- exports . createContext = createContext ;
167+ export { createContext } ;
0 commit comments