omniscientjs / omniscient

A library providing an abstraction for React components that allows for fast top-down rendering embracing immutable data for js

Home Page:http://omniscientjs.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Calling a function in the render function

jannavarro opened this issue · comments

So I have the omniscient component below. problem is the displayMessageIfError function does not appear to get written to the DOM. I also tried variations such as { displayMessageIfError} or {displayMessageIfError()} or {this.displayMessageIfError()}

component(function () {
    function displayMessageIfError(){
    return <div><p>Bad login information</p></div>;
 }

return (
<div>
    <form onSubmit={this.handleSubmit}>
      //some rendering here
      {displayMessageIfError}
    </form>
  </div>
}

Code seems invalid.

This is my interpretation and should work:

component(function () {
    function displayMessageIfError(){
        return <div><p>Bad login information</p></div>;
    }

    return (
        <div>
        <form onSubmit={this.handleSubmit}>
            //some rendering here
            {displayMessageIfError()}
        </form>
        </div>
    );
});

@dashed you are correct. That did work. I thought I did try that, probably I may have some typographical errors earlier. Thanks!