You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow configuration of swapComponent like resolveComponent to make automatic props transformation possible or introduce transformation function for setPage#2720
It would be great to be able to modify props before they reach components. The best example and use case is with Date objects.
For the application, it is a regular string, but thanks to regex on value or other methods or the key name in the object, we can automatically convert it to a Date object.
The components then receive the Date object directly instead of a string, which significantly simplifies subsequent work in the application without the need to define additional variables.
The first mount of the application can transform props during the setup function in createInertiaApp, which unfortunately is not sufficient for navigating to other pages and inertia requests.
Thanks to the customizability of swapComponent, similar transformations could be created for values other than just time. For example, converting numbers to the Decimal class or other specific business logic.
Since swapComponent uses unexported setPage and resolveRenderProps and sets other local variables such as component, page, key, and renderProps, it is not possible to make swapComponent easily customizable without further changes. A wrapper transformation function when assigning data to the page variable would be more than sufficient.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be great to be able to modify props before they reach components. The best example and use case is with Date objects.
For the application, it is a regular string, but thanks to regex on value or other methods or the key name in the object, we can automatically convert it to a Date object.
The components then receive the Date object directly instead of a string, which significantly simplifies subsequent work in the application without the need to define additional variables.
The first mount of the application can transform props during the
setupfunction increateInertiaApp, which unfortunately is not sufficient for navigating to other pages and inertia requests.Thanks to the customizability of
swapComponent, similar transformations could be created for values other than just time. For example, converting numbers to the Decimal class or other specific business logic.Since
swapComponentuses unexportedsetPageandresolveRenderPropsand sets other local variables such ascomponent,page,key, andrenderProps, it is not possible to makeswapComponenteasily customizable without further changes. A wrapper transformation function when assigning data to thepagevariable would be more than sufficient.setPageinside current svelte adapterPossible fueature implementation
transformDatais passed as simple prop intoAppcomponent. Default value can be simple method like(data) => data.Beta Was this translation helpful? Give feedback.
All reactions