admin管理员组文章数量:1202195
I'm using styled-components
in React-Native App.
Let's say I have link component:
import styled from 'styled-components/native';
const Link = styled.Text`
color: 'red';
&:hover {
color: 'blue';
}
`
After that, I 'compile' my React-Native code with react-native-web.
All is great expect that hover is not working. (Text color remains red
on hover.)
My guess is that is removing the hover
definition.
Any idea how to fix this?
I'm using styled-components
in React-Native App.
Let's say I have link component:
import styled from 'styled-components/native';
const Link = styled.Text`
color: 'red';
&:hover {
color: 'blue';
}
`
After that, I 'compile' my React-Native code with react-native-web.
All is great expect that hover is not working. (Text color remains red
on hover.)
My guess is that https://github.com/styled-components/css-to-react-native is removing the hover
definition.
Any idea how to fix this?
Share Improve this question edited Nov 12, 2018 at 18:20 kit 1,1735 gold badges17 silver badges23 bronze badges asked Aug 31, 2017 at 12:51 Dávid ĎurikaDávid Ďurika 1211 gold badge1 silver badge5 bronze badges 1- Maybe you can ref to my answer in onmouseenter event in react native – Li Zheng Commented Feb 15, 2021 at 8:14
4 Answers
Reset to default 7For native mobile development hover doesn't have a definition, that's because there is no cursor on the screen like there is on desktop devices. As React Native for web simulates how RN works, the :hover selector loose its sense
You can use onMouseEnter and onMouseLeave like in the refs section of styled-components. Advanced guide.
You can use rn-css that works like styled-components but with better support for css in React-Native.
Just replace import styled from 'styled-components/native';
with import styled from 'rn-css';
and your code will work.
Try use TouchableHighlight.
You can define the backgroundcolor when your button it's pressed or not!
Follow the guide on https://facebook.github.io/react-native/docs/touchablehighlight
本文标签: javascriptstyled components hover with reactnative and reactnativewebStack Overflow
版权声明:本文标题:javascript - styled components :hover with react-native and react-native-web - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738609692a2102561.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论