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

Full tree rendering without a DOM #249

Open
lelandrichardson opened this issue Mar 11, 2016 · 4 comments
Open

Full tree rendering without a DOM #249

lelandrichardson opened this issue Mar 11, 2016 · 4 comments
Labels
enhancement feature request Issues asking for stuff that would be semver-minor

Comments

@lelandrichardson
Copy link
Collaborator

We could implement a renderer that was like shallow in terms of lifecycle, and never actually attached to the DOM, but unlike shallow - rendered all the way down to leaf nodes:

function B(props) {
  return (
    <div className="b">
      <div>B</div>
      {props.children}
    </div>
  );
}
function A(props) {
  return (
    <B>
      <div>A</div>
      {this.props.children}
    </B>
  );
}
const wrapper = renderFull(<A>Root</A>);
wrapper.debug();

would output:

<A>
  <B>
    <div className="b">
      <div>B</div>
      <div>A</div>
      Root
    </div>
  </B>
</A>

(with a better name than renderFull of course)

@ljharb
Copy link
Member

ljharb commented Mar 11, 2016

Would this method call the componentWillMount and componentDidMount lifecycle methods?

@sjdemartini
Copy link

Interesting concept. What would be the primary differences between this and a mount? When would we prefer this over a mount?

@sjdemartini
Copy link

I suppose the main advantage would be that some components rendered in the tree may have behavior in componentDidMount that we don't want to execute or test (like DOM dependencies)?

@lelandrichardson
Copy link
Collaborator Author

@sjdemartini one big "advantage" over mount is that this function wouldn't require a document to be present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature request Issues asking for stuff that would be semver-minor
Projects
None yet
Development

No branches or pull requests

3 participants