Giter Club home page Giter Club logo

Comments (6)

supasate avatar supasate commented on May 25, 2024 2

I never try react-async-component also. Anyway, great to hear that your problem was solved!

from connected-react-router.

supasate avatar supasate commented on May 25, 2024

Hi @cescoferraro. I never try redux-observables. I'll check it.

Btw, could you provide a minimal repo that still causes this problem? Thanks!

from connected-react-router.

cescoferraro avatar cescoferraro commented on May 25, 2024

@supasate here its the branch I tried to hook up the connected-router.
https://github.com/cescoferraro/flag/compare/feature/connected-react-router?expand=1
Do you have a jsbin template I can try to reproduce this?

from connected-react-router.

cescoferraro avatar cescoferraro commented on May 25, 2024

its seems that it breaks here

history[method](...args)

from connected-react-router.

cescoferraro avatar cescoferraro commented on May 25, 2024

@supasate But the cause it most likely to be this

redux

@@router/LOCATION_CHANGE get fired twice by this simple button

import {push} from "connected-react-router";
@reduxForm({form: 'loginForm'})
@connect((state) => ({app: state.app}), AppActions)
export class LoginComponent extends React.Component<any, any> {

    render() {
        ... 
        <button onClick={()=>{
                    this.props.dispatch(push("/dashboard/workers"))
                    this.props.dispatch({type:"PONG"})
                }}>HELLO
                </button>
        }
}

from connected-react-router.

cescoferraro avatar cescoferraro commented on May 25, 2024

The issue here is this
https://github.com/ctrlplusb/react-async-component#server-side-rendering-application

withAsyncComponents renders the the whole app twice to do some optimizations (??), but removing it from the client side didnt seem to bother my async component what so ever. So problem solved.

now I get to use redux-observables and write cool epics

import { ajax } from 'rxjs/observable/dom/ajax';
import { push } from 'connected-react-router'

const fetchUser = username => ({ type: FETCH_USER, payload: username });

const fetchUserEpic = action$ =>
  action$.ofType(FETCH_USER)
    .mergeMap(action =>
      ajax.getJSON(`https://api.github.com/users/${action.payload}`)
        .map(response => push(`/dashboard/${action.payload}`))
    );

dispatch(fetchUser('torvalds'));

from connected-react-router.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.