How to use the @commercetools-uikit/hooks.usePrevious function in @commercetools-uikit/hooks

To help you get started, we’ve selected a few @commercetools-uikit/hooks 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 commercetools / ui-kit / src / components / inputs / localized-rich-text-input / editor.js View on Github external
const Editor = props => {
  const intl = useIntl();
  const ref = React.useRef();
  const prevIsFocused = usePrevious(props.editor.value.selection.isFocused);

  const [renderToggleButton, setRenderToggleButton] = React.useState(false);

  const { toggleLanguage } = props;
  const onToggle = React.useCallback(() => {
    toggleLanguage(props.language);
  }, [toggleLanguage, props.language]);

  const updateRenderToggleButton = React.useCallback(() => {
    const doesExceedCollapsedHeightLimit =
      ref.current.clientHeight > COLLAPSED_HEIGHT;

    if (doesExceedCollapsedHeightLimit && !renderToggleButton) {
      setRenderToggleButton(true);
    }
    if (!doesExceedCollapsedHeightLimit && renderToggleButton) {

@commercetools-uikit/hooks

A collection of React hooks used across some of the UI-Kit components.

MIT
Latest version published 5 days ago

Package Health Score

87 / 100
Full package analysis