You can see here:
ImageContext.js
import React from 'react';
const ImageContext = React.CreateContext('null');
export default ImageContext;
ImageUpload.js
return (
**<ImageContext.provider value={this.state.selectedFile.name}>**
<div>
<div style={mystyle} onClick={this.onNavToEditor}/>
<h1>File Upload Demo</h1>
<div >{this.state.uploadResult} onClick={this.onNavToEditor}</div>
<div>
<input type="file" onChange={this.onFileChange} />
<input type="text" value={this.state.value} onChange={this.onDescriptionChange} />
<button onClick={this.onFileUpload}>
Upload!
</button>
</div>
{this.listItems()}
</div>
</ImageContext.provider>
);
ImageEditor.js
return (
<ImageContext.Consumer>
{context => (
<div className="home-page">
<div className="center">
<h1>Photo Editor</h1>
<Button className='button' onClick={saveImageToDisk}>Save Image to Disk</Button>
</div>
<ImageEditor
includeUI={{
loadImage: {
path: context.path,
name: "image",
},
theme: myTheme,
menu: ["crop", "flip", "rotate", "draw", "shape", "text", "filter"],
initMenu: "",
uiSize: {
height: `calc(100vh - 160px)`,
},
menuBarPosition: "bottom",
}}
cssMaxHeight={window.innerHeight}
cssMaxWidth={window.innerWidth}
selectionStyle={{
cornerSize: 20,
rotatingPointOffset: 70,
}}
usageStatistics={true}
ref={imageEditor}
/>
</div>
)}
</ImageContext.Consumer>
);
I can send you more code if you need it.