3

I have been reading this, and I came across a line in the Redux documentation

Libraries like React attempt to solve this problem in the view layer by removing both asynchrony and direct DOM manipulation.

I understood the part where React does not allow DOM manipulations as it abstracts the actual rendering using the render() method. I am confused with the second part.

How does React remove the asynchrony? Can someone please explain with examples or valid use cases.

1
  • I think it removes async DOM manipulation by using Virtual DOM... so it does things before it changes the real DOM Commented Nov 30, 2016 at 13:30

2 Answers 2

4

It removes asynchronous behavior from the view layer by design. You must not do async stuff in render or what is rendered will be broken.

Libraries like React attempt to solve this problem in the view layer by removing both asynchrony and direct DOM manipulation [from the render method].

You are missing the last sentence which gives further explanations:

However, managing the state of your data is left up to you. This is where Redux enters.

To wrap up, there must be no async calls in render method but there can be some async stuff happening in the state management part handled by Redux. You can't do async stuff in the render method by design. If you you do so it won't work.

Sign up to request clarification or add additional context in comments.

Comments

0

I think that good example would be an rendering library like dust.js It renders template asynchronous, creates document fragment, and let user handle appending in callback.

And well... I think that any DOM mutations performed in callbacks counts into this case.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.