Skip to content

How Do I Include My Component in the Main Component #761

Answered by jgarte
jgarte asked this question in Q&A
Discussion options

You must be logged in to vote

Answer to self 🦆

All components must have a render function 📖

I didn't implement the render function:

fun render {
    <div><Counter/></div>
  }

Complete Example

component Counter {
  state counter = 0

  fun increment {
    next { counter: counter + 1 }
  }

  fun render {
    <div>
      <span>
        counter
      </span>

      <button onClick={increment}>
        "Increment"
      </button>
    </div>
  }
}

component Main {
  fun render {
    <Counter/>
  }
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gdotdesign
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant