I solved it, here's the new code
import React, {useState} from 'react';
import { EditorBlock } from 'draft-js';
export function ImageButton(props){
const [ imageURL, setImageURL ] = useState("");
//const [ insertURL, setInsertURL ] = useState("");
const propsData = Object.entries(props);
console.log(propsData[1][1]._map._root.entries[1][1])
function handleSelect(data){
setImageURL(data)
}
if(imageURL == ""){
return(
<div>
<p>Insert URL:</p>
<div>
<EditorBlock {...props}/>
</div>
<button onClick={() => handleSelect(propsData[1][1]._map._root.entries[1][1])}>Select</button>
</div>
)
}
else{
return(
<div>
<img src={imageURL} />
</div>
)
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…