isomorphic-style-loader icon indicating copy to clipboard operation
isomorphic-style-loader copied to clipboard

withStyles removes all component attributes

Open mar29th opened this issue 9 years ago • 4 comments

When I wrap my components with withStyles, the function essentially creates a fresh class, so all previously defined class attributes, such as static method or component functions are gone. The workaround I have so far is to manually add the attributes.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/38374870-withstyles-removes-all-component-attributes?utm_campaign=plugin&utm_content=tracker%2F26439769&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F26439769&utm_medium=issues&utm_source=github).

mar29th avatar Oct 14 '16 01:10 mar29th

You can call child component methods from parent like so: https://github.com/kriasoft/react-starter-kit/issues/909#issuecomment-252969542 Also withStyles copies all static method to new class in #38 (but not published yet)

frenzzy avatar Oct 14 '16 06:10 frenzzy

what about non-static values?

I'm trying to create an uncontrolled input, but withStyle makes [ComponentWithStyle].value undefined

rencar avatar Oct 24 '16 11:10 rencar

The same as in example above, just use this.child.value instead of this.child.method()

frenzzy avatar Oct 24 '16 14:10 frenzzy

https://github.com/thebigredgeek/isomorph-style-loader < There is an active fork here with the latest round of changes, including hoist-non-react-statics integration on the decorator

thebigredgeek avatar Oct 26 '16 22:10 thebigredgeek