Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flushChunkNames is empty #63

Closed
manish4781 opened this issue Jul 5, 2018 · 0 comments
Closed

flushChunkNames is empty #63

manish4781 opened this issue Jul 5, 2018 · 0 comments

Comments

@manish4781
Copy link

Hi @faceyspacey
i am trying to render my component on server, a component which fetches the data from another 3rd party API on componentDidMount, my component is rendering fine but when is pass the string returned from ReactDOM.renderToString to my .ejs file which is missing the data returned from 3rd party API

import React from 'react';
import ReactDOM from 'react-dom/server';
import { flushChunkNames } from 'react-universal-component/server';
import flushChunks from 'webpack-flush-chunks';

import App from '../shared/App';
import HorizontalModule from '../shared/Horizontal-module';
export default ({ clientStats }) => async (req, res) => {
    const app = (
        <App/>
    );
 
    const appString = ReactDOM.renderToString(app);
    const chunkNames = flushChunkNames();
    const { js, styles, cssHash } = flushChunks(clientStats, { chunkNames });
    res.render('index', {
        appString,
        js,
        styles,
        cssHash
    });

    console.log(appString);
};

my component is rendering fine, but when is see the view-source of a page component is empty.
appString is basically empty

currently my code for fetching data from API written in componentDidMount but i have tried componentWillMount as well

and this is my code base https://github.com/sharmam1/testproj

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

No branches or pull requests

1 participant