Comments (8)
@reinink onSuccess
or other eventListener doesn't work in my project but when I use then
it works. Do you have any idea
from inertia.
@sebastiandedeyne Is this still an issue in React, or have you found a sensible workaround here?
I ask because we've deprecated the visit promises in favour of the new event callbacks. However, if this problem still exists, we could potentially return the page object to the onSuccess()
callback.
from inertia.
This is still an issue. I think the onSuccess
callback is a good solution to this.
Maybe the new event system could provide a workaround, but I think that'd be a weird place to do that.
from inertia.
Yeah, okay cool. I think we can make this happen.
Next question then, should the onSuccess()
callback get the whole page object (url, version, props), or just the props?
Option 1 (entire page object)
return onSuccess(this.page)
Option 2 (props only)
return onSuccess(this.page.props)
Option 3 (treat props as the page, but include the url and version)
return onSuccess({
page: this.page.props,
url: this.page.url,
version: this.page.version,
})
So, this is tricky, because right now in the Vue.js adapter, $page
is actually just the props. We made this decision to avoid having to do $page.props
every time. However, there are times where having access to the URL would be nice ($page.url
), so I've considered adding a $url
property as well.
Either way...do we need to be consistent here?
from inertia.
To be honest, I kind of hate that we ever scoped page.props
to $page
in Vue.js. Yes, it's a nice convenience, but in reality I think it confuses what the "page" object is in Inertia.js. I kind of feel like we should move toward not doing this, and MAYBE even consider making this a change in the Vue.js adapter.
from inertia.
Okay, onSuccess()
now receives the page
object.
Considering this issue resolves. 🙌
from inertia.
@steven-lury Probably you're using an outdated version of Inertia, as the onSuccess
and other event listeners were introduced in @inertiajs/inertia
version 0.3.0
: https://github.com/inertiajs/inertia/releases/tag/v0.3.0
Could you try updating both the @inertiajs/inertia
package in your application, as well as your stack-specific (react, vue or svelte) Inertia adapter? I believe that should solve your issue.
from inertia.
I haven't found the reasoning on deprecating promises. Could someone elaborate for me?
Edit: Moving to discussions, sorry for the spam
from inertia.
Related Issues (20)
- Progress Indicator not working when switching pages HOT 1
- IsDirty keep at true after form submit
- Unintended browser redirection despite declining confirmation modal HOT 15
- Error handling argument issue HOT 1
- Rollup failed to resolve import fsevents to "default" is not exported by "lodash.clonedeep/index.js" HOT 1
- Drop remember mixin support HOT 2
- redirection to /dashboard after login does not work HOT 1
- Data props change from boolean (0/1) to string ("0"/"1") in production HOT 1
- Link component cannot be rendered as a custom component due to toLowerCase() HOT 1
- Incompatible with laravel vapor HOT 2
- Inertia crashes when a layer prop is not sent from server
- SSR | TypeError: Cannot read properties of undefined (reading 'getSSRProps') HOT 1
- Page doesn't get rendered HOT 1
- "undefined" is not valid JSON at JSON.parse in createInertiaApp() HOT 1
- Router methods type issues with wrong use of Exclude HOT 1
- [REQUEST] Router: make replace url optional HOT 2
- Form defaults() then reset() doesn't work as expected
- Make `data-page` hidration a new request HOT 7
- [1.1.0] Partial reload sets all $page props to undefined HOT 4
- [1.1.0] Partial reloads - Object props updated incorrectly
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from inertia.