Skip to content

Error: n.getChildContext(): childContextTypes must be defined in order to use getChildContext() #38

@vincentaudebert

Description

@vincentaudebert

Hi,

I'm trying to use unistore to rewrite react-accessible-accordion component.
I can't have it to work following the documentation.

I keep getting the following error on my "main" component (Accordion)
Error: n.getChildContext(): childContextTypes must be defined in order to use getChildContext()
(cf attached console screenshot)

My code is fairly basic:

// @flow

import React, { Component } from 'react';
import type { Node } from 'react';
import { createStore, Provider } from 'unistore/full/react';

type AccordionProps = {
    accordion: boolean,
    children: Node,
    className: string,
    onChange: Function,
    activeItems: Array<string | number>,
};

class Accordion extends Component<AccordionProps, *> {
    static defaultProps = {
        accordion: true,
        onChange: () => {},
        className: 'accordion',
        activeItems: [],
    };

    store = createStore({
        accordion: this.props.accordion,
        onChange: this.props.onChange,
        activeItems: this.props.activeItems,
    });

    render() {
        const { className, accordion, children } = this.props;
        return (
            <Provider store={this.store}>
                <div>Test</div>
            </Provider>
        );
    }
}

export default Accordion;

screen shot 2017-12-14 at 2 48 47 pm

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions