Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't override renderBody method on SignupModal component #21

Open
mayask opened this issue Feb 28, 2016 · 2 comments
Open

Can't override renderBody method on SignupModal component #21

mayask opened this issue Feb 28, 2016 · 2 comments

Comments

@mayask
Copy link

mayask commented Feb 28, 2016

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?

@capouch
Copy link

capouch commented Jul 16, 2016

@myaskevich did you ever find a fix/workaround for this?

@mayask
Copy link
Author

mayask commented Jul 16, 2016

@capouch
You can pass your own content as component's children like so:

<SignupModal title="Обратная связь" buttonText="Отправить" modalId="feedback-modal" onSubmit={onFeedback}>
  <div>
    <SignupModal.Input name="name" label="Имя" placeholder="Имя"/>
    <SignupModal.Input type="email" name="email" required label="E-mail" placeholder="E-mail"/>
    <SignupModal.TextArea rows="6" name="message" required label="Сообщение" placeholder="Сообщение"/>
  </div>
</SignupModal>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants