reacton icon indicating copy to clipboard operation
reacton copied to clipboard

Accept a function as initial value for use_state

Open koenvo opened this issue 9 months ago • 0 comments

This PR adds the possibility to use a function as inital value for use_state. This is in line with how React works: https://react.dev/reference/react/useState#usestate

When it's costly to calculate the initial value you don't want to rerun it every time the component is rerendered. Therefore, we need to only calculate it once.

koenvo avatar Apr 03 '25 14:04 koenvo