use-force-render
Allows forcing the rendering of the webcomponent without the need to be tied to a state or property
Since the version of [email protected]* there is the useUpdate hook, with the same functionality but in the core of Atomico.

Modulo

1
import { useForceRender } from "@atomico/hooks/use-force-render";
Copied!

Syntax

1
const forceRender = useForceRender();
Copied!
Where:
  1. 1.
    forceRender: Callback to force rendering of the webcomponent.

Example

Sometimes the rendering of the webcomponent does not depend on a state or property of this, to reflect these changes you can use useForceRender to regenerate the DOM, example:
1
function component() {
2
const ref = useRef();
3
const forceRender = useForceRender();
4
5
return (
6
<host>
7
{ref.current.anyProp}
8
<my-component ref={ref} onclick={forceRender}></my-component>
9
</host>
10
);
11
}
Copied!
Copy link
Edit on GitHub