How to use the @webiny/app/components.useUi function in @webiny/app

To help you get started, we’ve selected a few @webiny/app 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 webiny / webiny-js / packages / app-admin / src / components / withSnackbar.js View on Github external
export const useSnackbar = () => {
    const ui = useUi();

    return {
        showSnackbar: (message, options) => {
            ui.setState(ui => {
                return { ...ui, snackbar: { message, options } };
            });
        },
        hideSnackbar: () => {
            ui.setState(ui => {
                return { ...ui, snackbar: null };
            });
        }
    };
};
github webiny / webiny-js / packages / app-admin / src / hooks / useSnackbar.js View on Github external
export const useSnackbar = () => {
    const ui = useUi();

    return {
        showSnackbar: (message, options) => {
            ui.setState(ui => {
                return { ...ui, snackbar: { message, options } };
            });
        },
        hideSnackbar: () => {
            ui.setState(ui => {
                return { ...ui, snackbar: null };
            });
        }
    };
};