question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expected subtree parent to be a mounted class component

See original GitHub issue

Hi, Getting this error when trying to mount my component: image

The Component with the tooltip seems to be working fine on its own. when I tried to mount it as a child in this FeedCard it causes the crash.

Code:

FeedCard:

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { ListItem, Person, StayIndicator } from '@guestyci/atomic-design/dist/v2/components';
import FeedCardInfo from './FeedCardInfo';

class FeedCard extends Component {
  render() {
    const { isSelected } = this.props;
    return (
      <ListItem
        dense
        className="bg-hover-white flex-column px-3 bb-1 border-gray"
        onClick={this.handleCardClick}
        isSelected={isSelected}
        selectedClassName="bg-white box-shadow-light"
      >
        <FeedCardInfo lastMessageTimestamp="2011-10-05T14:48:00.000Z" />
        <div className="flex-space-between-center">
          <Person name="Bob" className="mb-3" />
          <StayIndicator status="pre" />
        </div>
      </ListItem>
    );
  }
}
export default FeedCard;

StayIndicator:

import React from 'react';
import PropTypes from 'prop-types';
import { StayStatus } from '../../../constants/enums';
import Tooltip from '../tooltip/Tooltip';
import BaseStayIndicator from './BaseStayIndicator';

const tooltips = {
  [StayStatus.Reserved]: 'Reserved',
  [StayStatus.Planned]: 'Upcoming stay',
  [StayStatus.Staying]: 'Currently staying',
  [StayStatus.Complete]: 'Checked out',
};

const StayIndicator = ({
  status,
  large,
  className,
  style,
  dark,
  width,
  id,
  fill,
}) => (
  <Tooltip body={tooltips[status]} id={id} containerClassName="d-flex-fill">
    <BaseStayIndicator
      width={width}
      dark={dark}
      status={status}
      style={style}
      className={className}
      large={large}
      fill={fill}
    />
  </Tooltip>
);
StayIndicator.defaultProps = {
  status: StayStatus.Planned,
  large: false,
  className: '',
  style: {},
  width: undefined,
  dark: false,
  id: undefined,
  fill: false,
};

StayIndicator.propTypes = {
  /** Stay status - Enum (StayStatus- [Reserved, Planned, Staying, Complete,]) */
  status: PropTypes.oneOf([
    StayStatus.Planned,
    StayStatus.Staying,
    StayStatus.Complete,
    StayStatus.Reserved]),
  /** Indicator whether to use large component size */
  large: PropTypes.bool,
  /** Additional class to add to StayIndicator */
  className: PropTypes.string,
  /** Additional style to add to StayIndicator */
  style: PropTypes.shape(),
  /** Customize line width */
  width: PropTypes.number,
  /** Set theme to dark */
  dark: PropTypes.bool,
  /** Id for the stay indicator component */
  id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
  /** Set the stay indicator to fill space */
  fill: PropTypes.bool,
};

export default StayIndicator;


Tooltip (if it helps):

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import cn from 'classnames';
import StrapTooltip from 'reactstrap/lib/Tooltip';
import { uuid } from '../../../utils/commonUtility';
import { Theme } from '../../../constants/enums';
import './tooltip.scss';

class Tooltip extends Component {
  constructor(props) {
    super(props);
    this.state = { isOpen: false, id: props.id || uuid() };
  }
  onToggle = () => {
    this.setState(prevState => ({ isOpen: !prevState.isOpen }));
  };
  render() {
    const {
      children, className, body, style, autoHide, theme,
      placement, offset, containerClassName, ...props
    } = this.props;
    const { id, isOpen } = this.state;
    return (
      <div className={containerClassName}>
        <span className={containerClassName} id={`Tooltip-${id}`}>{children}</span>
        <StrapTooltip
          innerClassName="box-shadow-heavy"
          target={`Tooltip-${id}`}
          isOpen={isOpen}
          toggle={this.onToggle}
          className={cn('mx-2', 'my-2', { 'light-theme': theme === Theme.Light }, className)}
          style={style}
          autohide={autoHide}
          placement={placement}
          offset={offset}
          {...props}
        >
          {body}
        </StrapTooltip>
      </div>
    );
  }
}
export default Tooltip;

using: React: 16.52, React-DOM: 16.52, ReactStrap: 6.3.1

Can someone please assist? Issue only appears when hovering over component

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
SandMoshicommented, Oct 22, 2019

If this is happening as a result of you updating react or konva/react-konva packages, this fix may work for you:

  1. delete the node_modules folder
  2. run npm install again.
  3. Afterwards, run npm run start again.

This fixed the error for me.

5reactions
RajuRoopanicommented, Feb 15, 2019

@Jony-Y / @chasestarr could you please explain the fix? i ran into the same problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Expected subtree parent to be a mounted class component ...
"Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue."...
Read more >
Expected subtree parent to be a mounted class component ...
[Solved]-"Expected subtree parent to be a mounted class component. " after extracting component-Reactjs. to my webpack. config it works now.
Read more >
expected subtree parent to be a mounted class component ...
I've got below error after upgrading React to 16.5 Uncaught Error: Expected subtree parent to be a mounted class component. This error is...
Read more >
konvajs/konva - Gitter
I had an error: "Expected subtree parent to be a mounted class component". Error showed whenever I tried to export my component that...
Read more >
Full DOM Rendering · Enzyme - GitHub Pages
options.wrappingComponent : ( ComponentType [optional]): A component that will render as a parent of the node . It can be used to provide ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found