javascriptreactjszoomingmetadisable

React JS How to disable zoom


Im building a web app and I want to disable the zoom with 2 fingers. I have tried this

meta name="viewport" content=" width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"

but is not working. The app will run on tablets.

Thank you !


Solution

  • With the React-Helmet you can put your metadata in the render-function of your Component like this:

    render(){ 
        return <div>
            <Helmet>
                  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
            </Helmet>
            [...]
        </div>
    }
    

    Look at the Helmet documentation for further information.