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

Javascript Rendered Apps (React, Angular) #57

Open
oliverbenns opened this issue May 4, 2016 · 6 comments
Open

Javascript Rendered Apps (React, Angular) #57

oliverbenns opened this issue May 4, 2016 · 6 comments

Comments

@oliverbenns
Copy link

oliverbenns commented May 4, 2016

Same issue as here, but I'm using React. This will be a common issue for most Js rendered apps.

So requiring in the file automatically runs a function that goes through all the DOM elements and adds the various fallback styles, and giving you access to window.flexibility.

We need to be able to recalculate or re-run the self invoking function when we re-render areas of the site. .walk and .init doesn't really work as we won't always know the elements to render due to app's dynamic nature, and we should really be able to just define with -js-display: flex.

Ideally we would also be able to assign flexibility as a variable and use it when we need to, not whenever we require it and have it as a global variable.

E.g.

import flexibility from 'flexibility';

// Initial page render
render(foo, function() {
   flexibility.init(); // Not attached to window, and this is the first initialisation!
});

// On React component / Angular controller update
render(bar, function() {
   flexibility.update(); // Recalculate whole DOM
});
@oliverbenns oliverbenns changed the title Javascript Rendered Apps Javascript Rendered Apps (React, Angular) May 4, 2016
@JulioC
Copy link

JulioC commented May 5, 2016

Is there any workaround for forcing this re-init already?

@oliverbenns
Copy link
Author

oliverbenns commented May 5, 2016

I attempted triggering a resize event in hope that it would re-calculate and apply styles, but to no avail.

I'm going to try using walk at some point, passing the universal selector into document.querySelector() when grabbing dom elements, but I imagine this will be very performance heavy.

@rennat-eb
Copy link

I got flexibility to work for our react components by adding:

...
    _updateFlexibility () {
        flexibility.walk(ReactDOM.findDOMNode(this));
    }

    componentDidMount () {
        this._updateFlexibility();
    }

    componentDidUpdate () {
        this._updateFlexibility();
    }
...

unfortunately our flex layout was too much for flexibility right away (several layers nested)

It sort-of worked, but failed to handle flex-direction: rows-reversed; and failed flex: 1 0 auto; on one child. We'll continue investigating because this would be a big win for us.

@reintroducing
Copy link

I apologize for resurrecting this but has there been any headway on this in the 2.x release? If not, what is the officially suggested way of using this in a React app?

@danawoodman
Copy link

Bump...

@jackdh
Copy link

jackdh commented Aug 9, 2018

Any Update?

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

6 participants