Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
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
Grégoire Locqueville
purescript-gargantext
Commits
0eab4c4a
Unverified
Commit
0eab4c4a
authored
Nov 28, 2018
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Loader] add an explicit guard in componentDidUpdate
parent
1fff8e1e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
Loader.purs
src/Gargantext/Components/Loader.purs
+7
-3
No files found.
src/Gargantext/Components/Loader.purs
View file @
0eab4c4a
...
@@ -48,9 +48,13 @@ createLoaderClass' name loader render =
...
@@ -48,9 +48,13 @@ createLoaderClass' name loader render =
pure { state: s.state
pure { state: s.state
, render: s.render
, render: s.render
, componentDidMount: dispatcher this ForceReload
, componentDidMount: dispatcher this ForceReload
, componentDidUpdate: \_prevProps
_prevState
_snapshot -> do
, componentDidUpdate: \_prevProps
{currentPath}
_snapshot -> do
{path} <- React.getProps this
{path} <- React.getProps this
dispatcher this (SetPath path)
-- This guard is the same as in performAction (SetPath ...),
-- however we need it here to avoid potential infinite loops.
-- https://reactjs.org/docs/react-component.html#componentdidupdate
when (path /= currentPath) do
dispatcher this (SetPath path)
})
})
where
where
initialState {path} = {currentPath: path, loaded: Nothing}
initialState {path} = {currentPath: path, loaded: Nothing}
...
@@ -60,7 +64,7 @@ createLoaderClass' name loader render =
...
@@ -60,7 +64,7 @@ createLoaderClass' name loader render =
loaded <- lift $ loader currentPath
loaded <- lift $ loader currentPath
modifyState_ $ _ { loaded = Just loaded }
modifyState_ $ _ { loaded = Just loaded }
performAction (SetPath newPath) _ {currentPath} =
performAction (SetPath newPath) _ {currentPath} =
when (newPath /= currentPath)
$
do
when (newPath /= currentPath) do
loaded <- lift $ loader newPath
loaded <- lift $ loader newPath
modifyState_ $ _ { currentPath = newPath, loaded = Just loaded }
modifyState_ $ _ { currentPath = newPath, loaded = Just loaded }
...
...
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