Skip to content

Commit d6cdfd9

Browse files
author
Michael Trotter
committed
Move displayName functions to FFI
1 parent d6ff680 commit d6cdfd9

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/node_modules/
33
/.pulp-cache/
44
/output/
5+
/generated-docs/
56
/.psc-package/
67
/.psc*
78
/.purs*

src/React/Basic.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,11 @@ exports.fragmentKeyed_ = function(key, children) {
227227
[Fragment, { key: key }].concat(children)
228228
);
229229
};
230+
231+
exports.displayNameFromComponentSpec = function($$spec) {
232+
return $$spec.$$type.displayName || "[unknown]";
233+
};
234+
235+
exports.displayNameFromSelf = function(self) {
236+
return exports.displayNameFromComponentSpec(self.instance_.$$spec);
237+
};

src/React/Basic.purs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ module React.Basic
2020
, element
2121
, elementKeyed
2222
, toReactComponent
23+
, displayNameFromComponentSpec
24+
, displayNameFromSelf
2325
) where
2426

2527
import Prelude
@@ -278,14 +280,12 @@ foreign import toReactComponent
278280
. ComponentSpec { | props } state state action
279281
-> ReactComponent { | props }
280282

281-
displayNameFromComponentSpec
283+
foreign import displayNameFromComponentSpec
282284
:: forall props state initialState action
283285
. ComponentSpec props state initialState action
284286
-> String
285-
displayNameFromComponentSpec = _.displayName <<< unsafeCoerce <<< _."$$type"
286287

287-
displayNameFromSelf
288+
foreign import displayNameFromSelf
288289
:: forall props state action
289290
. Self props state action
290291
-> String
291-
displayNameFromSelf = _.dislpayName <<< _."$$type" <<< _."$$spec" <<< unsafeCoerce <<< _.instance_

0 commit comments

Comments
 (0)