Field label bound to a createModel accessor crashes: scheduleExploreIfVisible is not a function

オープン 初心者向け
#1,345 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
frontend

調査の方向性

Field.initから始めます。issueで指摘されているラベルのチェックと、提案されているisAccessorChainの処理を確認し、アクセサーとセレクターのヘルパーを調べてその動作を確認します。createModelを使ったTextFieldの例で再現し、動作するbind形式と比較します。アクセサーチェーンがラベルテキストとして扱われ、最初の探索時にフィールドがエラーをスローしなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

<TextField label={m.$page.labels.key} /> with m = createModel<...>() throws TypeError: ins.scheduleExploreIfVisible is not a function from Widget.explore when the field is first explored. label={bind(m.$page.labels.key)} works.

TypeError: ins.scheduleExploreIfVisible is not a function
    at TextField.explore (Widget)
    at TextField.explore (PureContainer)
    at TextField.explore (Field)
    at Instance.explore

Cause: Field.init tests this.label.isComponentType before isSelector(this.label):

if ((this.label as any).isComponentType) labelConfig = this.label;
else if (isSelector(this.label)) labelConfig.text = this.label;
else Object.assign(labelConfig, this.label);

An accessor chain is a Proxy whose every property is a truthy accessor, so it is taken for a component and used as the label widget. isSelector would not catch it either, since config.type is truthy on the proxy.

Suggested fix: in Field.init, check isAccessorChain(this.label) first and set labelConfig.text = this.label. Consider making isSelector return true for accessor chains, so other props typed StringProp | Config behave the same.

Seen on cx 26.7.0.

主要言語
TypeScript
スター
492
フォーク
72
平均マージ
21分
マージ済み PR(30日)
4

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

codaxy/cxjs のほかの issue

codaxy/cxjs の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。