3

I am using React, Redux, Redux Router, and Redux Form for a web application, and I would like to implement an "edit" form. The form lives under the URL /components/1/edit.

When the form is successfully submitted I would like to redirect to /components/1 and display a toast with a confirmation message. I can get the redirect to work by hooking into react-form's props.submitSucceeded and rendering a <Redirect/> tag.

But I am not sure how to propagate the confirmation message so that it is displayed.

Ideally something like the React/Redux take on flash messages in Ruby on Rails.

Anvar
  • 1,110
  • 2
  • 10
  • 22
  • 2
    In the code block that renders your `` you're going to want to dispatch an action that updates the store. Example: `dispatch({ type: "SHOW_TOAST", message });` You'll want to have a `` component that is connected to the store and returns null if it's message prop is empty. When it has a message, it returns the markup of your toast with the message displayed. – Kyle Richardson Jul 25 '17 at 14:40
  • Ok, thank you, that makes sense! Also found this with a bit more information about how to structure the flash messages themselves: https://alexzywiak.github.io/react-redux-a-flash-messenger-example/index.html – Anvar Jul 25 '17 at 14:47
  • Glanced at it very briefly, but looks solid at a glance. – Kyle Richardson Jul 25 '17 at 14:50

0 Answers0