How to use @restart/context - 5 common examples

To help you get started, we’ve selected a few @restart/context examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 4Catalyzer / found / src / createBaseRouter.js View on Github external
value={{
              router: this.router,
              match: renderArgs,
            }}
          >
            {element}
          
        
      );
    }
  }

  BaseRouter.propTypes = propTypes;

  // FIXME: For some reason, using contextType doesn't work here.
  return mapContextToProps(
    {
      consumers: ReactReduxContext,
      mapToProps: ({ store }) => ({ store }),
      displayName: 'withStore(BaseRouter)',
    },
    BaseRouter,
  );
}
github react-bootstrap / react-bootstrap / src / AbstractNav.js View on Github external
return (
      
        
          
        
      
    );
  }
}

export default mapContextToProps(
  [SelectableContext, TabContext],
  (parentOnSelect, tabContext, { role }) => {
    if (!tabContext) return { parentOnSelect };

    const { activeKey, getControllerId, getControlledId } = tabContext;
    return {
      activeKey,
      parentOnSelect,
      role: role || 'tablist',
      // pass these two through to avoid having to listen to
      // both Tab and Nav contexts in NavLink
      getControllerId,
      getControlledId,
    };
  },
  AbstractNav,
github react-bootstrap / react-bootstrap / src / ThemeProvider.js View on Github external
function createBootstrapComponent(Component, opts) {
  if (typeof opts === 'string') opts = { prefix: opts };
  const isClassy = Component.prototype && Component.prototype.isReactComponent;
  // If it's a functional component make sure we don't break it with a ref
  const { prefix, forwardRefAs = isClassy ? 'ref' : 'innerRef' } = opts;

  return forwardRef(
    // eslint-disable-next-line react/prop-types
    ({ className, float, ...props }, ref) => {
      props[forwardRefAs] = ref;
      const prefixes = useContext(ThemeContext);
      let floats = null;
      if (float && Object.keys(float).length > 0) {
        floats = Object.entries(float).reduce(
          (acc, [property, value]) =>
            acc +
            (property !== 'default'
              ? `float-${property}-${value} `
              : `float-${value} `),
          '',
        );
      }
      return (
github 4Catalyzer / found / src / withRouter.js View on Github external
export default function withRouter(Component) {
  return mapContextToProps(
    {
      consumers: RouterContext,
      mapToProps: context => context,
      displayName: `withRouter(${Component.displayName || Component.name})`,
    },
    Component,
  );
}
github react-bootstrap / react-bootstrap / www / src / components / Heading.js View on Github external
if (!registerNode) return;
    registerNode(parseInt(h, 10), title, id);
  }

  render() {
    const { h, id, children, className } = this.props;
    const H = `h${h}`;
    return (
      
        <div>{children}</div>
      
    );
  }
}

export default mapContextToProps(
  TocContext,
  c =&gt; ({ registerNode: c.registerNode }),
  Heading,
);

@restart/context

React context helpers.

MIT
Latest version published 5 years ago

Package Health Score

53 / 100
Full package analysis

Similar packages