How to use the @restart/context/forwardRef function in @restart/context

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 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 (

@restart/context

React context helpers.

MIT
Latest version published 6 years ago

Package Health Score

53 / 100
Full package analysis

Similar packages