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 callback argument to render() #45

Closed
mindplay-dk opened this issue Sep 26, 2019 · 4 comments
Closed

Add callback argument to render() #45

mindplay-dk opened this issue Sep 26, 2019 · 4 comments

Comments

@mindplay-dk
Copy link
Contributor

I just noticed in React docs that there's a third argument callback in ReactDOM's render() function:

ReactDOM.render(element, container[, callback])

According to the docs:

If the optional callback is provided, it will be executed after the component is rendered or updated.

This would be very useful for testing, at least.

What do you think about adding support for this?

@yisar
Copy link
Collaborator

yisar commented Sep 26, 2019

Maybe we can do the same with options? For example, I rewrote commitWork here

mindplay-dk added a commit to mindplay-dk/fre that referenced this issue Sep 26, 2019
…s the right way - and had to change `defer` to `setTimeout` for now, as I'm not sure if `requestAnimationFrame` even works with `jsdom` in the first place?
mindplay-dk added a commit to mindplay-dk/fre that referenced this issue Sep 26, 2019
…s the right way - and had to change `defer` to `setTimeout` for now, as I'm not sure if `requestAnimationFrame` even works with `jsdom` in the first place?
@yisar
Copy link
Collaborator

yisar commented Oct 5, 2019

Hey, let's continue to talk about this. For our test, I think we can add callbacks, but I'm sorry it may take a few days because our school Internet is not work yet.

@yisar
Copy link
Collaborator

yisar commented Oct 5, 2019

I added options.resolve callback, which seems to solve the current problem.
here
It uses like this :

new Promise((resolve, reject) => {
  options.resolve = resolve
  render(<App />, root)
})

It is set by options and executed after the DOM operations.

@mindplay-dk
Copy link
Contributor Author

Looks like this is done :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants