Skip to content

Latest commit

 

History

History
54 lines (43 loc) · 1.51 KB

v8.md

File metadata and controls

54 lines (43 loc) · 1.51 KB

Migrate cozy-bar from v8 to v11

To migrate cozy-bar from v8 (or v9, v10, which is the same as v8) to v11, follow these steps:

  1. Update the cozy-bar in your project by running the following command:

     yarn add cozy-bar@11.0.0
  2. You need to add the cozy-bar CSS import 'cozy-bar/dist/stylesheet.css' into your index or an other file

  3. You can remove the bar initialization. Generally you can search for cozy.bar.init({

  4. Add the BarComponent into your layout like the following code:

    import { BarComponent } from 'cozy-bar'
    
    const App = () => {
        return (
            <Layout>
                <BarComponent />
            </Layout>
        )
    }
  5. If you were using customs elements, you need to wrap the BarComponent and your elements into a BarProvider. Generally you can add this into providers file:

    <BarProvider>
        <OtherProvider>
            {children}
        </OtherProvider>
    </BarProvider>
  6. Then, replace { BarLeft } = cozy.bar with a direct import:

    import { BarLeft } from 'cozy-bar'
    
    const Title = ({ title }) => {
        const { isMobile } = useBreakpoints()
    
        if(isMobile) {
            return (
                <BarLeft>{title}</BarLeft>
            )
        }
        return (
            <h2>{title}</h2>
        )
    }
  7. You no longer need to include the providers inside your custom bar element. Now, you can access all the providers that wrap the BarComponent directly within your custom element.