Search code examples
javascriptreactjsreact-nativemonoreporeact-native-web

Is there alternative to use outline:"none" property in react native?


Actually, i have passed style {{ width: "100%", outline: "none", height: 50 }} to the child component, to which i am getting a warning in the terminal that outline is not valid property. If this style declared in the stylesheet, the app crashed with an error, therefore it has to be declared inline. I could not found a way to remove the warning, since react native don't support outline : "none" property, is there any other alternative to this.


Solution

  • You can use the Platform API from react native web to only add the outline style when your app is running on web.

    Something like:

    StyleSheet.create({
      textEditStyle: {
        Platform.select({
          web: {
            outline: 'none'
          }
        }),
        ... // Other styles go here
      }
    });