Skip to content

Can't override renderBody method on SignupModal component #21

@mayask

Description

@mayask

I created a custom component based on SignupModal:

import React from "react";
import {
  SignupModal
} from "neal-react";

export class FeedbackModal extends SignupModal {
  renderBody() {
    if (this.props.children) return this.props.children;
    return (
      <div>
        <SignupModal.Input name="name" label="Имя" placeholder="Имя"/>
        <SignupModal.Input type="email" name="email" required label="E-mail" placeholder="E-mail"/>
        <SignupModal.TextArea name="message" required label="Сообщение" placeholder="Сообщение"/>
      </div>
    );
  }
}

Then i'm using it like so:

<FeedbackModal title="Обратная связь" buttonText="Отправить" modalId="feedback-modal" onSubmit={onFeedback}/>
<p>
    <a className="btn btn-primary btn-ghost" data-toggle="modal" data-target="#feedback-modal">Оставить отзыв</a>
</p>

The problem is that the original renderBody is getting called.

I tried to override a render method as well to examine which class the renderBody's method prototype belongs to. It turns out it points to the original SignupModal class.

Why is this happening? I'm quite new to ES6, but haven't found anyone having similar issues.
Is it because neal-react ships already transpiled code?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions