-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Redux: Provide Redux store instance to Layout
component
#1800
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,9 +79,7 @@ function init() { | |
} ); | ||
} | ||
|
||
function setUpContext( layout ) { | ||
var reduxStore = createReduxStore(); | ||
|
||
function setUpContext( layout, reduxStore ) { | ||
// Pass the layout so that it is available to all page handlers | ||
// and add query and hash objects onto context object | ||
page( '*', function( context, next ) { | ||
|
@@ -140,6 +138,7 @@ function loadDevModulesAndBoot() { | |
|
||
function boot() { | ||
var layoutSection, layout, validSections = []; | ||
var reduxStore = createReduxStore(); | ||
|
||
init(); | ||
|
||
|
@@ -163,6 +162,7 @@ function boot() { | |
// Create layout instance with current user prop | ||
Layout = require( 'layout' ); | ||
layout = ReactDom.render( React.createElement( Layout, { | ||
store: reduxStore, | ||
user: user, | ||
sites: sites, | ||
focus: layoutFocus, | ||
|
@@ -194,7 +194,7 @@ function boot() { | |
window.history.replaceState( null, document.title, window.location.pathname ); | ||
} | ||
|
||
setUpContext( layout ); | ||
setUpContext( layout, reduxStore ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had to do the same :) |
||
|
||
page( '*', require( 'lib/route/normalize' ) ); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ var React = require( 'react' ), | |
property = require( 'lodash/utility/property' ), | ||
sortBy = require( 'lodash/collection/sortBy' ); | ||
|
||
import { Provider } from 'react-redux'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
|
@@ -99,7 +101,7 @@ module.exports = React.createClass( { | |
sectionClass += ' has-no-sidebar'; | ||
} | ||
|
||
return ( | ||
const layout = ( | ||
<div className={ sectionClass }> | ||
{ config.isEnabled( 'keyboard-shortcuts' ) ? <KeyboardShortcutsMenu /> : null } | ||
<Masterbar user={ this.props.user } section={ this.state.section } sites={ this.props.sites }/> | ||
|
@@ -121,5 +123,11 @@ module.exports = React.createClass( { | |
isActive={ translator.isActivated() }/> | ||
</div> | ||
); | ||
|
||
return ( | ||
<Provider store={ this.props.store }> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You will have problems with everything that uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.com/Automattic/wp-calypso/pull/1496/files#diff-40142ad60b0ab946a566d1d4933afab8L306 |
||
{ layout } | ||
</Provider> | ||
); | ||
} | ||
} ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont know if we really need that - we can connect components that need access to store using
connect
down the line.