preact#RenderableProps TypeScript Examples

The following examples show how to use preact#RenderableProps. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: audio.tsx    From big-web-quiz with Apache License 2.0 6 votes vote down vote up
render({ state, children }: RenderableProps<Props>) {
    if (state !== this._lastState) {
      this._lastState = state;
      this._lockedChildren = this._lastChildren;
      this._audio.then(async audio => {
        if (state === 'play') {
          audio.playLoop();
        } else if (state === 'upgrade') {
          await audio.upgradeLoop();
        } else if (state === 'stop') {
          await audio.playStab();
        }

        this._lockedChildren = undefined;
        // Trigger a render
        this.setState({});
      });
    }

    this._lastChildren = children;
    return this._lockedChildren || children;
  }
Example #2
Source File: vs.tsx    From big-web-quiz with Apache License 2.0 6 votes vote down vote up
VS: FunctionalComponent<Props> = ({
  colorFrom,
  colorTo,
  children,
}: RenderableProps<Props>) => (
  <div
    class="vs-circle"
    style={{
      '--color-from': colorFrom || '',
      '--color-to': colorTo || '',
    }}
  >
    <div class="vs-outer vs-outer-1"></div>
    <div class="vs-outer vs-outer-2"></div>
    <div class="vs-outer vs-outer-3"></div>
    <div class="vs-outer vs-outer-4"></div>
    <div class="vs-innermost-circle">{children || 'VS'}</div>
  </div>
)
Example #3
Source File: index.tsx    From big-web-quiz with Apache License 2.0 6 votes vote down vote up
render({ children }: RenderableProps<Props>) {
    const childArray = toChildArray(children);

    if (toChildArray(children).length > 1) {
      throw Error('<Transition/> may only have one child');
    }

    const [child] = childArray;

    const updatingCurrent =
      !this._currentChild ||
      (!childIsVNode(child) && !childIsVNode(this._currentChild)) ||
      (childIsVNode(child) &&
        childIsVNode(this._currentChild) &&
        child.type === this._currentChild.type &&
        child.key === this._currentChild.key);

    if (!updatingCurrent) {
      this._transitioningOut = this._currentChild;
      this._pendingTransition = true;
    }

    this._currentChild = child;

    return (
      <div class="transition-grid">
        {[this._transitioningOut || <div />, child || <div />]}
      </div>
    );
  }