fusionjs / fusion-plugin-connected-react-router

Migrated to https://github.com/fusionjs/fusionjs
MIT License
2 stars 9 forks source link

@@router/LOCATION_CHANGE events fired off multiple times on page load #43

Open ardok opened 5 years ago

ardok commented 5 years ago

Event @@router/LOCATION_CHANGE gets fired off 4x on page load. Looked around online and it seems like there's nothing mentioning this issue.

Type of issue

Bug?

Description

@@router/LOCATION_CHANGE action should get fired once on page load.

Current behavior

@@router/LOCATION_CHANGE action gets fired 4x on page load. image

They all have the same exact payload.

{
  type: '@@router/LOCATION_CHANGE',
  payload: {
    location: {
      pathname: '/',
      search: '',
      hash: ''
    },
    action: 'POP',
    isFirstRendering: false
  }
}

Expected behavior

There should only be one @@router/LOCATION_CHANGE

Steps to reproduce

  1. Follow the README to install this plugin on your Fusion app
  2. Load a page.

Your environment

ardok commented 5 years ago

I tried setting up connected-react-router from fresh app using create-react-app, and it's properly firing @@router/LOCATION_CHANGE only once.

image

{
  type: '@@router/LOCATION_CHANGE',
  payload: {
    location: {
      pathname: '/fy18/Phase-4/TASK-40234',
      search: '',
      hash: ''
    },
    action: 'POP',
    isFirstRendering: false
  }
}

So, this must be something to do with Fusion, or the way I set it up. Could you think of any reason that could cause the action getting fired 4x on page load?

ganemone commented 5 years ago

This plugin isn't super well supported right now. It was built as a proof of concept. I recommend keeping routing logic separate from the redux store and using the withRouter hoc to get access to routing related props.