Radium: Wrapping custom components

Created on 19 Feb 2016  路  1Comment  路  Source: FormidableLabs/radium

I am trying to use material-ui with Radium. Now given that Radium doesn't mess with the style prop of non-DOM elements I would have to use the wrapper workaround suggested in the FAQ:

A workaround is to wrap your custom component in Radium, even if you do not have the source, like this:
var Link = require('react-router').Link; Link = Radium(Link);

However, this will not work with ES6 module imports as the imported components are read only.

import RaisedButton from 'material-ui/lib/raised-button'; RaisedButton = Radium(RaisedButton);
this will not compile.

Is there a way around it?

Most helpful comment

Use a new variable name instead of reassigning it:

import RaisedButton from 'material-ui/lib/raised-button'; 
const RadiumRaisedButton = Radium(RaisedButton); 

or

import {RaisedButton as OriginalRaisedButton} from 'material-ui/lib/raised-button'; 
const RaisedButton = Radium(OriginalRaisedButton); 

>All comments

Use a new variable name instead of reassigning it:

import RaisedButton from 'material-ui/lib/raised-button'; 
const RadiumRaisedButton = Radium(RaisedButton); 

or

import {RaisedButton as OriginalRaisedButton} from 'material-ui/lib/raised-button'; 
const RaisedButton = Radium(OriginalRaisedButton); 
Was this page helpful?
0 / 5 - 0 ratings