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

how to pass action into popover body? #167

Open
thisroot opened this issue Jan 17, 2018 · 2 comments
Open

how to pass action into popover body? #167

thisroot opened this issue Jan 17, 2018 · 2 comments

Comments

@thisroot
Copy link

thisroot commented Jan 17, 2018

Hi, i try to pass close action into to popover body, but it cant work fo me. Where i get mistake?

togglePopover(toState) {
    const popoverIsOpen =
      typeof toState === 'boolean' ? toState : !this.state.popoverIsOpen;
    this.setState({
      popoverIsOpen,
    });
  }

...
    const popoverProps = {
      isOpen: this.state.popoverIsOpen,
      preferPlace: 'end',
      onOuterAction: e => {
        this.togglePopover(false);
      },
      body: [
        <div key="b" className={cx('popover-body')}>
          <div>
            <ChangeDayForm
              date={date}
              dayName={dayName}
              dayNum={dayNum}
              dayTypeId={dayTypeId}
              dayTypeName={dayTypeName}
              dayStart={dayStart}
              dayStop={dayStop}
              onCloseCard={e => this.togglePopover(false)}
            />
          </div>
        </div>,
      ],
    };

class ChangeDayForm extends Component {
  constructor(props) {
    super(props);
  }

  render() {
 
   ...
    return (
   ....
              <Button onClick={this.props.onCloseCard}>Отмена</Button>
    );
  }
}
@jhardin293
Copy link

Same problem over here.
Tried passing markup to body prop using string and array syntax but still cant register actions/events.

@valentinvoilean
Copy link

Create an external component, then render it inside the popoverProps.body.

const Test = () => (
    <div key="b" onClick={() => console.log('works')}>
      Popover contents
    </div>
);

....

const popoverProps = {
    ...
    body: <Test />,
  };

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

3 participants