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

pass SSR context #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

pass SSR context #25

wants to merge 1 commit into from

Commits on Oct 18, 2015

  1. pass SSR context

    This PR concerns this issue on FlowRouter : kadirahq/flow-router#205
    
    When ReactLayout.render is called asynchronousely, the ssr context is not accessible anymore. This is a double PR (I'ma making the same for DocHead). It just add the context as an optionnal parametter of the render and _addToHead functions.
    
    So in the action hook of the route constructor in flow router, you can now do this :
    
    	action( params, queryParams ) {
    
    		let context;
    		if ( Meteor.isServer )
    			context = FlowRouter.ssrContext.get();
    
    		Meteor.call( 'getAsyncData', ( err, data ) => {
    		
    			DocHead.setTitle( data.title, context );
    		
    			DocHead.addMeta( {
    				name: 'description',
    				content: data.description
    			}, context );
    		
    			ReactLayout.render( ReactLayouts.MainLayout, {
    				content: <ReactView.MyView data={ data } />,
    			}, context );
    		
    		} );
    
    	}
    
    There's probably a smarter way, but this one works.
    fabien-h committed Oct 18, 2015
    Configuration menu
    Copy the full SHA
    40cec29 View commit details
    Browse the repository at this point in the history