Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
* Baobab-React Mixins
* ====================
*
* Old style react mixins.
*/
import PropTypes from './utils/prop-types';
import {solveMapping} from './utils/helpers';
import Baobab from 'baobab';
const makeError = Baobab.helpers.makeError;
/**
* Helpers
*/
function displayName(instance) {
return (instance.constructor || {}).displayName || 'Component';
}
/**
* Root mixin
*/
const RootMixin = {
// Component prop types
propTypes: {
tree: PropTypes.baobab
/**
* Baobab-React Higher Order Component
* ====================================
*
* ES6 state of the art higher order component.
*/
import React from 'react';
import Baobab from 'baobab';
import {curry, isBaobabTree, solveMapping} from './utils/helpers';
import PropTypes from './utils/prop-types';
const makeError = Baobab.helpers.makeError,
isPlainObject = Baobab.type.object;
/**
* Helpers
*/
function displayName(Component) {
return Component.name || Component.displayName || 'Component';
}
function invalidMapping(name, mapping) {
throw makeError(
'baobab-react/higher-order.branch: given cursors mapping is invalid (check the "' + name + '" component).',
{mapping}
);
}
import React, {useContext, useState, useEffect} from 'react';
import {isBaobabTree} from './utils/helpers';
import Baobab from 'baobab';
import BaobabContext from './context';
const makeError = Baobab.helpers.makeError,
isPlainObject = Baobab.type.object;
function invalidMapping(name, mapping) {
throw makeError(
'baobab-react/hooks.useBranch: given cursors mapping is invalid (check the "' + name + '" component).',
{mapping}
);
}
export function useRoot(tree) {
if (!isBaobabTree(tree))
throw makeError(
'baobab-react/hooks.useRoot: given tree is not a Baobab.',
{target: tree}
);