I have a button on my homepage that redirects to my controller: redirect_to edit_user_path(user, track: "homepage")
I can see that the redirect works correctly because if I throw a pry inside the controller it'll freeze.
The edit action inside my users_controller renders a react page. I am using the react rails gem.
When I visit the users/:id/edit page it works properly but for whatever reason when I go thru the redirect it doesn't load properly.
# edit.html.erb
`<%= react_component("App", @data) %>`
# users_controller#edit
# GET users/:id/edit
def edit
@tracking = params[:track] if params[:track].present?
@data = {name: "steve", age: 33, track: @tracking}
end
It almost looks like all of the props are missing because the react developer tools says: "waiting for roots to load..."
I think you got the redirect code wrong. Can you try this in the redirection controller?
redirect_to edit_user_path(user, track: "homepage")
Use redirect_to
instead of return
Turns out it was a timing issue. The link I was using had turbolinks enabled. When I changed turbolinks to be false everything worked as expected.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.