kadirahq / mantra

Mantra - An Application Architecture for Meteor
https://kadirahq.github.io/mantra/
978 stars 52 forks source link

Problem with Routing and Alert #197

Closed RemyLespagnol closed 8 years ago

RemyLespagnol commented 8 years ago

Hi,

I use a mantra architecture for my application. For verify user's email I have a route (FlowRouter) to handle this url. When Meteor validate the mail, I want to redirect to the home page of my website and show an Alert message (with https://github.com/juliancwirko/react-s-alert).

So for this I use the LocalState (ReactiveDict) to put this information.

In the container of the home page, I put an Alert :

import {useDeps, composeAll, composeWithTracker, compose} from 'mantra-core';

import BoardLayout from '../components/board_layout.jsx';

import Alert from 'react-s-alert';

export const composer = ({context}, onData) => {
  const {Meteor, Collections, LocalState} = context();
  // Don't use Localstate for this example
  Alert.success('Some message',{onRouteClose: false, timeout: 10000});

  if(Meteor.user()){
    const profileImg = Meteor.user().profile.profileImg;
    onData(null, {profileImg});
  }
  else{
    onData(null, {});
  }
};

export const depsMapper = (context, actions) => ({
  context: () => context
});

export default composeAll(
  composeWithTracker(composer),
  useDeps(depsMapper)
)(BoardLayout);

And when I go to this container (FlowRouter.go('/')), the page is loaded but no message was rendered.

But, if I reload the page (so without a redirection in the code) the Alert is showing.

So I don't know with Alert show on direct page loading but not when I redirect with flowrouter.

Thanks.