Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-reactix
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
purescript-reactix
Commits
0eb368de
Commit
0eb368de
authored
Apr 18, 2019
by
James Laver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make component creation functions take a name for React devtools
parent
7b2514bc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
10 deletions
+19
-10
React.js
src/Reactix/React.js
+2
-0
React.purs
src/Reactix/React.purs
+17
-10
No files found.
src/Reactix/React.js
View file @
0eb368de
...
@@ -46,3 +46,5 @@ exports._createContext = function(ctor, val) {
...
@@ -46,3 +46,5 @@ exports._createContext = function(ctor, val) {
};
};
exports
.
_render
=
function
(
a
,
b
)
{
return
react_dom
.
render
(
a
,
b
);
};
exports
.
_render
=
function
(
a
,
b
)
{
return
react_dom
.
render
(
a
,
b
);
};
exports
.
_named
=
function
(
name
,
f
)
{
f
.
name
=
name
;
return
f
;
};
src/Reactix/React.purs
View file @
0eb368de
...
@@ -71,16 +71,18 @@ instance componentesqueMemo :: Componentesque Memo
...
@@ -71,16 +71,18 @@ instance componentesqueMemo :: Componentesque Memo
-- | Creates a pure leaf component from a function
-- | Creates a pure leaf component from a function
pureLeaf ::
pureLeaf ::
forall props. Childless props
forall props. Childless props
=> (Record props -> Element)
=> String
-> (Record props -> Element)
-> Component props
-> Component props
pureLeaf
f =
Component (mkEffectFn1 $ pure <<< f)
pureLeaf
name f = named named $
Component (mkEffectFn1 $ pure <<< f)
-- | Creates a pure tree component from a function
-- | Creates a pure tree component from a function
pureTree ::
pureTree ::
forall props. Childless props
forall props. Childless props
=> (Record props -> Array Element -> Element)
=> String
-> (Record props -> Array Element -> Element)
-> Component (WithChildren props)
-> Component (WithChildren props)
pureTree
c =
Component $ mkEffectFn1 c'
pureTree
name c = named name $
Component $ mkEffectFn1 c'
where
where
c' :: Record (WithChildren props) -> Effect Element
c' :: Record (WithChildren props) -> Effect Element
c' props = pure $ c (unsafeCoerce props) (children props.children)
c' props = pure $ c (unsafeCoerce props) (children props.children)
...
@@ -88,18 +90,20 @@ pureTree c = Component $ mkEffectFn1 c'
...
@@ -88,18 +90,20 @@ pureTree c = Component $ mkEffectFn1 c'
-- | Creates a hooks leaf component from a function
-- | Creates a hooks leaf component from a function
hooksLeaf ::
hooksLeaf ::
forall props. Childless props
forall props. Childless props
=> (forall m. MonadHooks m => Record props -> m Element)
=> String
-> (forall m. MonadHooks m => Record props -> m Element)
-> Component props
-> Component props
hooksLeaf
c =
Component (mkEffectFn1 c)
hooksLeaf
name c = named name $
Component (mkEffectFn1 c)
hooksTree ::
hooksTree ::
forall props. Childless props
forall props. Childless props
=> (forall m. MonadHooks m
=> String
-> (forall m. MonadHooks m
=> Record props
=> Record props
-> Array Element
-> Array Element
-> m Element)
-> m Element)
-> Component (WithChildren props)
-> Component (WithChildren props)
hooksTree
c =
Component $ mkEffectFn1 c'
hooksTree
name c = named name $
Component $ mkEffectFn1 c'
where
where
c' :: Record (WithChildren props) -> Effect Element
c' :: Record (WithChildren props) -> Effect Element
c' props = c (unsafeCoerce props) (children props.children)
c' props = c (unsafeCoerce props) (children props.children)
...
@@ -191,8 +195,6 @@ children = _children
...
@@ -191,8 +195,6 @@ children = _children
-- Context
-- Context
-- | A React Context
-- | A React Context
...
@@ -242,6 +244,11 @@ readNullableRef = toMaybe <<< _deref
...
@@ -242,6 +244,11 @@ readNullableRef = toMaybe <<< _deref
-- foreign import _forwardRef :: forall r p. (Fn2 p r Element) -> Forwarded p
-- foreign import _forwardRef :: forall r p. (Fn2 p r Element) -> Forwarded p
named :: forall c. String -> c -> c
named = runFn2 named
foreign import _named :: forall c. Fn2 String c c
foreign import _isValid :: forall a. a -> Boolean
foreign import _isValid :: forall a. a -> Boolean
isValid :: forall a. a -> Boolean
isValid :: forall a. a -> Boolean
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment