About attach_hook/4 after callback

Components are always good for menu state. You can use attach_hook for handle_params to store the params or uri in state then pass that to a menu component which can do the calculation (so long as it’s a pure calculation, of course).