use editor mount for loading instead of carbon's

main
Mike Fix 6 years ago
parent db0d4ad728
commit d16df95bda

@ -224,7 +224,7 @@ class Carbon extends React.PureComponent {
return ( return (
<div className="section"> <div className="section">
<div className="export-container" ref={this.props.innerRef} id="export-container"> <div className="export-container" ref={this.props.innerRef} id="export-container">
<SpinnerWrapper>{content}</SpinnerWrapper> <SpinnerWrapper loading={this.props.loading}>{content}</SpinnerWrapper>
<div className="twitter-png-fix" /> <div className="twitter-png-fix" />
</div> </div>
<style jsx> <style jsx>

@ -42,7 +42,8 @@ class Editor extends React.Component {
super(props) super(props)
this.state = { this.state = {
...DEFAULT_SETTINGS, ...DEFAULT_SETTINGS,
preset: DEFAULT_PRESET_ID preset: DEFAULT_PRESET_ID,
loading: true
} }
this.export = this.export.bind(this) this.export = this.export.bind(this)
@ -80,7 +81,8 @@ class Editor extends React.Component {
// Load from localStorage // Load from localStorage
...getSettings(localStorage), ...getSettings(localStorage),
// and then URL params // and then URL params
...initialState ...initialState,
loading: false
} }
// Makes sure the slash in 'application/X' is decoded // Makes sure the slash in 'application/X' is decoded
@ -334,12 +336,13 @@ class Editor extends React.Component {
{/*key ensures Carbon's internal language state is updated when it's changed by Dropdown*/} {/*key ensures Carbon's internal language state is updated when it's changed by Dropdown*/}
<Carbon <Carbon
key={language} key={language}
ref={this.carbonNode}
config={this.state} config={this.state}
onChange={this.updateCode} onChange={this.updateCode}
onAspectRatioChange={this.updateAspectRatio} onAspectRatioChange={this.updateAspectRatio}
titleBar={titleBar} titleBar={titleBar}
updateTitleBar={this.updateTitleBar} updateTitleBar={this.updateTitleBar}
ref={this.carbonNode} loading={this.state.loading}
> >
{code != null ? code : DEFAULT_CODE} {code != null ? code : DEFAULT_CODE}
</Carbon> </Carbon>

@ -2,13 +2,7 @@ import React from 'react'
import Spinner from 'react-spinner' import Spinner from 'react-spinner'
export default function SpinnerWrapper(props) { export default function SpinnerWrapper(props) {
const [loading, setLoading] = React.useState(true) if (props.loading) {
React.useEffect(() => {
setLoading(false)
}, [])
if (loading) {
return ( return (
<div> <div>
<Spinner /> <Spinner />

Loading…
Cancel
Save