Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Bootstrap not passing proper context on SSR #14

Copy link
Copy link
@jcampalo

Description

@jcampalo
Issue body actions

With the latest react version I'm unable to make this library work, for some reason react-tree-walker is not able to keep the context of the provider.

I was able to reproduce the error inside the asyncBootstrapper.test.js:

`
import React, { Component } from 'react'
import asyncBootstrapper from '../'

const ThemeContext = React.createContext('light')

describe('asyncBootstrapper()', () => {
let values = []
let actualContext
let contextValue

class DeprecatedAPI extends Component {
asyncBootstrap() {
values.push(this.props.id)
return true
}

render() {
  return <div>{this.props.children}</div>
}

}

class NewAPI extends Component {
bootstrap() {
values.push(this.props.id)
actualContext = this.context
return true
}

render() {
  return <div>{this.props.children}</div>
}

}

const app = Foo => (
<ThemeContext.Provider value='dark'>


Test





<ThemeContext.Consumer>
{value => {
contextValue = value
return value
}}
</ThemeContext.Consumer>



</ThemeContext.Provider>
)

beforeEach(() => {
values = []
})

it('deprecated API', () =>
asyncBootstrapper(app(DeprecatedAPI)).then(() =>
expect(values).toEqual([1, 2, 4, 3]),
))

it('new API', () =>
asyncBootstrapper(app(NewAPI), null, { bespokeContext: true }).then(() => {
expect(values).toEqual([1, 2, 4, 3])
expect(actualContext).toEqual({
bespokeContext: true,
reactAsyncBootstrapperRunning: true,
})
expect(contextValue).toEqual('dark')
}))
})
`

Updating the react version to 16.6.3 you should be able to reproduce the error.

jdwillemse

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.