Skip to content
This repository has been archived by the owner on Dec 15, 2018. It is now read-only.

Fragments do not get updated #55

Closed
marcselman opened this issue Sep 1, 2016 · 4 comments
Closed

Fragments do not get updated #55

marcselman opened this issue Sep 1, 2016 · 4 comments

Comments

@marcselman
Copy link

Hi,

I'm using the latest version 8.0.0.

I create my store like this:

let store = createStore(
    rootReducer,
    initialState,
    createStoreWithRouter({
        routes,
        pathname: '/',
        forServerRender: typeof window == 'undefined'
    })
);

And my root element is:

<RouterProvider store={store}>
    <Provider store={store}>
        <App />
    </Provider>
</RouterProvider>

I have some testing elements like this:

<div>
    <Link href='/messages'>Go messaging!</Link>
    <Fragment forRoute='/messages'>
        <div>
            We're messaging!
            <Link href='/'>Go home!</Link>
        </div>
    </Fragment>
</div>

When I click the link the URL changes but the fragment stays the same untill I manually force a rerender.

PS: Also it looks like Fragment can only have one child at max, why is that?

Thanks,
Marc

@dpwrussell
Copy link

To answer the PS. It can definitely take multiple children.

From https://facebook.github.io/react/docs/reusable-components.html

// Anything that can be rendered: numbers, strings, elements or an array
// (or fragment) containing these types.
optionalNode: React.PropTypes.node,

@marcselman
Copy link
Author

I agree but somehow I receive an error when having more than one child:

<Fragment forRoute='/messages'>
    <div>more</div>
    <div>
        We're messaging!
        <Link href='/'>Go home!</Link>
    </div>
</Fragment>

Fragment(...): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.

@marcselman
Copy link
Author

Thanks to the just posted sample files I was able to find the problem.
I wrapped around but it should have been the other way around.
Now it works!

@tptee
Copy link
Contributor

tptee commented Sep 5, 2016

Glad that helped! Sorry I didn't get to this sooner!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants