Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

275
Views
StencilJS @Prop() variable is undefined

I created a stencil component () that uses another stencil component () in the rendered template.

One of the props (key: string) passed from smg-compound-filter to smg-filter is undefined, whereas the other props are well defined. I made sure that {filter.key} is defined in the template of smg-compound-filter, and i even tried to pass a literal string to smg-filter, but it's undefined in this component. I think i am missing something. If someone could give me an insight, it will be bery helpful.

smg-compound-filter.ts (render function)

  render() {
    return (
        <div class="smg-filter-container">

            <div class={`filters`}>
                    this.filters.map(filter => {
                        return (
                            <div class='filter'>
                                <smg-filter
                                    key={filter.key} // even "str" doesn't work
                                    label={filter.label}
                                    target={filter.target}
                                    options={filter.options}
                                    customClasses='secondary'
                                    onFilterChanged={(event) => {this.toggleOption(event)}}
                                >
                                </smg-filter>
                            </div>
                        );
                    })
            </div>
        </div>
    );
  }

smg-filter.ts

export class SmgFilter {
  @State() filter: Filter;

  @State() showOptions: boolean;

  /** custom classes to adapt style */
  @Prop() customClasses: string;

  /** smartsheet column linked to the filter */
  @Prop() key: string;

  /** label of the filter */
  @Prop() label: string;

  /** options */
  @Prop() options: FilterOption[];

  /** type of products to be filtered: 'master' or 'product' */
  @Prop() target: FilterTarget;

  @Event() filterChanged: EventEmitter<Filter>;

  componentWillLoad() {
    console.log(this.key); // undefined

    this.showOptions = !isSecondary ? true : false;
    this.filter = {
        key: this.key,
        target: this.target,
        label: this.label,
        options: this.options,
    };
  }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

That's because key is a reserved keyword since Stencil uses it to improve loop rerender performance.

I'm not 100% sure if it can be changed or disabled but I think you'll have to use another property name.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!