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

Sign up
Appearance settings

Add options to callbacks #7

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

Open
sjparsons wants to merge 1 commit into ctrlplusb:master
base: master
Choose a base branch
Loading
from sjparsons:add-options-to-callbacks

Conversation

Copy link

@sjparsons sjparsons commented Mar 20, 2018

Hi, it would be useful to be able to pass the options object in the asyncBootstrapper down into the individual asyncBootstrap callbacks.

Here's an example.

class Foo extends Component {
 asyncBootstrap(options) {
 // options = {key1: 'val'}
 return true
 }
 render() {
 return <div>{this.props.children}</div>
 }
 }
asyncBootstrapper(app, {key1: 'val'}).then(() => {
 ReactDOM.render(app, document.getElementById('app'))
})

This PR makes that change and also adds a test to assert this funtionality.

ctrlplusb reacted with thumbs up emoji
Copy link

codecov bot commented Mar 20, 2018

Codecov Report

Merging #7 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@ Coverage Diff @@
## master #7 +/- ##
=====================================
 Coverage 100% 100% 
=====================================
 Files 1 1 
 Lines 5 5 
 Branches 1 1 
=====================================
 Hits 5 5
Impacted Files Coverage Δ
src/index.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0ec74a4...46327e0. Read the comment docs.

Copy link
Owner

Hey @sjparsons, thanks for this. It definitely sounds like a useful feature, thanks! I will review it quite soon as I am gonna be doing some updates to this lib. 👍

Copy link
Owner

ctrlplusb commented Mar 21, 2018
edited
Loading

Hey @sjparsons, so I have updated this library to use the latest version of react-tree-walker. At the same time I reviewed the options we were passing down to react-tree-walker. I have now exposed the ability to provide a React "context" to your component tree for bootstrapping. This essentially can satisfy your requirements in an alternative manner.

e.g.

class Foo extends Component {
 bootstrap() {
 console.log(this.context.myBootstrapSetting)
 }
 render() {
 return <div>foo</div>
 }
}
bootstrapper(<Foo />,null,{myBootstrapSetting:'what_ever_you_need'})
 .then(() => console.log('done'))

As you can see it's a new third parameter to the bootstrapper.

I think it would be best to keep the secondary options parameter separate and specific to the bootstapper/react-tree-walker configuration.

What do you think?

You may have noticed I am using bootstrap instead of asyncBootstrap. Both work, however, asyncBootstrap will be removed in next major release.

wvbe reacted with thumbs up emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /