Created
September 21, 2018 15:23
-
-
Save asci/03af662ec168ea0339943f6c6ba1a656 to your computer and use it in GitHub Desktop.
share data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
import { PropertyControls, ControlType } from 'framer'; | |
import { data } from './Examples'; | |
// Define type of property | |
interface Props { | |
text: string; | |
} | |
export class Display extends React.Component<Props> { | |
constructor(props) { | |
super(props); | |
this.state = { | |
num: data.rotation.get() || 'empty', | |
}; | |
} | |
componentDidMount() { | |
data.rotation.onUpdate(({ value }) => { | |
this.setState({ num: value }); | |
}); | |
} | |
// Set default properties | |
static defaultProps = { | |
text: 'Hello World!', | |
}; | |
// Items shown in property panel | |
static propertyControls: PropertyControls = { | |
text: { type: ControlType.String, title: 'Text' }, | |
}; | |
render() { | |
const style = { | |
backgroundColor: 'red', | |
width: this.state.num + '%', | |
}; | |
return ( | |
<div> | |
<div style={style}>{this.state.num}</div> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Artem, could you also share the Slider component where you set the data.rotation? Thanks for taking the time to help us with this