-
Notifications
You must be signed in to change notification settings - Fork 12
Fixing forceUpdate not working in latest versions of React #188
Conversation
Deploy preview for catwalk-qlikcore ready! Built with commit 992501a |
@@ -165,7 +165,9 @@ export default function HypercubeTable({ | |||
const hypercubeProps = createProperties(dimensions, measures); | |||
const model = useModel(app, hypercubeProps); | |||
const layout = useLayout(model); | |||
|
|||
if (!model) { | |||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want a "loading" thingie here instead of null
?
src/components/cubes.jsx
Outdated
@@ -39,7 +39,7 @@ export function Cubes({ app, closeOnClickOutside }) { | |||
|
|||
function openColumnChooser() { | |||
addOpen.current = true; | |||
forceUpdate(); | |||
forceUpdate(Date.now()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be nicer with a const forceUpdate = useForce();
hook, that did the Date.now()
magic behind the scenes, so you'd still just do forceUpdate()
. That way we can keep the logic in one place and change it easily in the future if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a useForce hook using a bool instead of Date.now().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Closing #187