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

Can i render every element with different render function? #5902

Closed
darkautism opened this issue Jan 22, 2016 · 2 comments
Closed

Can i render every element with different render function? #5902

darkautism opened this issue Jan 22, 2016 · 2 comments

Comments

@darkautism
Copy link

I need some element only have html, and do not need data-reactid.

But I don't except i should render two element with different function( e.g. renderToStaticMarkup, renderToString) and combine it because the element could be include by many element. Render split and combine could cause mistake when element is much more.

If i could set an attribute in compoment:

class DefaultLayout extends  React.Component{    
    render() {
        return (
            <html></html>
        );
    }
};
DefaultLayout.noNeedDiffCompoment = true;
export default DefaultLayout;

or a new pure html Compoment

class DefaultLayout extends  React.PureHtmlComponent{    
    render() {
        return (
            <html></html>
        );
    }
};
export default DefaultLayout;

If i write as above, the render function can auto swap render function to render elements.

Is there any graceful solution?

@jimfb
Copy link
Contributor

jimfb commented Jan 22, 2016

What you are looking for is shouldComponentUpdate. If shouldComponentUpdate returns false, that tells React that your component doesn't need to rerender.

For future reference, this is a usage question, rather than a bug in the React core. Usage questions are better answered on sites like StackOverflow, as we try to use github issues for tracking bugs in the React core. For this reason, I'm going to close out this issue, but feel free to continue the conversation here or move it to StackOverflow.

@darkautism
Copy link
Author

Thanks your reply, but the server side render useing renderToString will not call shouldComponentUpdate.
And i will move this topic into StackOverflow, many thanks.

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

No branches or pull requests

2 participants