score:0

class Test {

    // ...

    funScript() {
        const code = ("" + this.state.code).replace(/this/ig, "__self__");
        const execute = new Function("__self__", code);
        execute(this);
    }

    // ...
}

score:1

<button onClick={this.funScript()} >run</button>

Related Query

More Query from same tag