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

add location object to loadProps #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 9 additions & 7 deletions modules/AsyncProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function filterAndFlattenComponents(components) {
return flattened
}

function loadAsyncProps({ components, params, loadContext }, cb) {
function loadAsyncProps({ components, params, location, loadContext }, cb) {
let componentsArray = []
let propsArray = []
let needToLoadCounter = components.length
Expand All @@ -44,7 +44,7 @@ function loadAsyncProps({ components, params, loadContext }, cb) {
maybeFinish()
} else {
components.forEach((Component, index) => {
Component.loadProps({ params, loadContext }, (error, props) => {
Component.loadProps({ params, location, loadContext }, (error, props) => {
const isDeferredCallback = hasCalledBack[index]
if (isDeferredCallback && needToLoadCounter === 0) {
cb(error, {
Expand Down Expand Up @@ -93,10 +93,11 @@ function createElement(Component, props) {
return <Component {...props}/>
}

export function loadPropsOnServer({ components, params }, loadContext, cb) {
export function loadPropsOnServer({ components, params, location }, loadContext, cb) {
loadAsyncProps({
components: filterAndFlattenComponents(components),
params,
location,
loadContext
}, (err, propsAndComponents) => {
if (err) {
Expand Down Expand Up @@ -223,8 +224,8 @@ const AsyncProps = React.createClass({
return

const { enterRoutes } = computeChangedRoutes(
{ routes: this.props.routes, params: this.props.params },
{ routes: nextProps.routes, params: nextProps.params }
{ routes: this.props.routes, params: this.props.params, location: this.props.location },
{ routes: nextProps.routes, params: nextProps.params, location: nextProps.location }
)

const indexDiff = nextProps.components.length - enterRoutes.length
Expand Down Expand Up @@ -261,6 +262,7 @@ const AsyncProps = React.createClass({
loadAsyncProps({
components: filterAndFlattenComponents(components),
params,
location,
loadContext
}, this.handleError((err, propsAndComponents) => {
const reloading = options && options.reload
Expand All @@ -287,8 +289,8 @@ const AsyncProps = React.createClass({
},

reloadComponent(Component) {
const { params } = this.props
this.loadAsyncProps([ Component ], params, null, { reload: true })
const { params, location } = this.props
this.loadAsyncProps([ Component ], params, location, { reload: true })
},

render() {
Expand Down