<commit_before>import { Children, Component, createContext, createElement } from "react"
import { shallowEqual } from "./utils/utils"

const specialReactKeys = { children: true, key: true, ref: true }

export const MobXProviderContext = createContext({})

export class Provider extends Component {
    static contextType = MobXProviderContext

    constructor(props, context) {
        super(props, context)
        this.state = {
            ...context,
            ...grabStores(props)
        }
    }

    render() {
        return createElement(
            MobXProviderContext.Provider,
            { value: this.state },
            Children.only(this.props.children)
        )
    }

    static getDerivedStateFromProps(nextProps, prevState) {
        if (process.env.NODE_ENV !== "production") {
            const newStores = { ...prevState, ...grabStores(nextProps) } // spread in prevState for the context based stores
            if (!shallowEqual(prevState, newStores))
                throw new Error(
                    "MobX Provider: The set of provided stores has changed. Please avoid changing stores as the change might not propagate to all children"
                )
        }
        return prevState // because they didn't change, remember!
    }
}

function grabStores(from) {
    const res = {}
    if (!from) return res
    for (let key in from) if (validStoreName(key)) res[key] = from[key]
    return res
}

function validStoreName(key) {
    return !specialReactKeys[key] && key !== "suppressChangedStoreWarning"
}
<commit_msg>Add the displayName static property to the Provider component (#711)<commit_after>import { Children, Component, createContext, createElement } from "react"
import { shallowEqual } from "./utils/utils"

const specialReactKeys = { children: true, key: true, ref: true }

export const MobXProviderContext = createContext({})

export class Provider extends Component {
    static contextType = MobXProviderContext
    static displayName = "MobXProvider"

    constructor(props, context) {
        super(props, context)
        this.state = {
            ...context,
            ...grabStores(props)
        }
    }

    render() {
        return createElement(
            MobXProviderContext.Provider,
            { value: this.state },
            Children.only(this.props.children)
        )
    }

    static getDerivedStateFromProps(nextProps, prevState) {
        if (process.env.NODE_ENV !== "production") {
            const newStores = { ...prevState, ...grabStores(nextProps) } // spread in prevState for the context based stores
            if (!shallowEqual(prevState, newStores))
                throw new Error(
                    "MobX Provider: The set of provided stores has changed. Please avoid changing stores as the change might not propagate to all children"
                )
        }
        return prevState // because they didn't change, remember!
    }
}

function grabStores(from) {
    const res = {}
    if (!from) return res
    for (let key in from) if (validStoreName(key)) res[key] = from[key]
    return res
}

function validStoreName(key) {
    return !specialReactKeys[key] && key !== "suppressChangedStoreWarning"
}

{'fraction_non_alphanumeric': 0.09784979744468682, 'fraction_numerical': 0.0009348706762231225, 'mean_word_length': 2.512035010940919, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1149914', 'n_tokens_mistral': 883, 'n_tokens_neox': 845, 'n_words': 258}