pixi-fusion
Version:
This module offers a set of common components needed for playing games.
15 lines (14 loc) • 442 B
JavaScript
import { useEffect } from "react";
import { useWorld } from ".";
export const useTickerCallback = ({ isEnabled = true, callback }) => {
const { application } = useWorld();
useEffect(() => {
if (!application || !isEnabled) {
return;
}
application.ticker.add(callback);
return () => {
application.ticker.remove(callback);
};
}, [isEnabled, application, callback]);
};