[React] Styling a React button component with Radium
React's inline styles allow components to stand on their own by not requiring any external CSS. However HTML's style attributes don't support pseudo selectors like :hover and :active. By using Radium to listen to mouse events we can restore :hover and :active selectors to inline styles.
const { render } = ReactDOM
const rootEl = document.getElementById('root')
const Div = Radium(({children}) => {
return (
<div style={style}>
{children}
</div>
);
});
const style = {
backgroundColor: '#07d',
border: 'none',
borderRadius: 4,
color: '#fff',
padding: '5px 20px',
':hover': {
backgroundColor: '#08f'
}
}
render(<Div>OK</Div>, rootEl)
So, just need to wrap the compoment in to Radium() method.
[React] Styling a React button component with Radium的更多相关文章
- [React] Styling React Components With Aphrodite
Aphrodite is a library styling React components. You get all the benefits of inline styles (encapsul ...
- [React Native] Using the Image component and reusable styles
Let's take a look at the basics of using React Native's Image component, as well as adding some reus ...
- React.Component 与 React.PureComponent(React之性能优化)
前言 先说说 shouldComponentUpdate 提起React.PureComponent,我们还要从一个生命周期函数 shouldComponentUpdate 说起,从函数名字我们就能看 ...
- [React] Refactor a Stateful List Component to a Functional Component with React PowerPlug
In this lesson we'll look at React PowerPlug's <List /> component by refactoring a normal clas ...
- 十九、React UI框架Antd(Ant Design)的使用——及react Antd的使用 button组件 Icon组件 Layout组件 DatePicker日期组件
一.Antd(Ant Design)的使用:引入全部Css样式 1.1 antd官网: https://ant.design/docs/react/introduce-cn 1.2 React中使用A ...
- React.createClass 、React.createElement、Component
react里面有几个需要区别开的函数 React.createClass .React.createElement.Component 首选看一下在浏览器的下面写法: <div id=" ...
- [React] Use React.memo with a Function Component to get PureComponent Behavior
A new Higher Order Component (HOC) was recently released in React v16.6.0 called React.memo. This be ...
- React源码 React.Component
React中最重要的就是组件,写的更多的组件都是继承至 React.Component .大部分同学可能都会认为 Component 这个base class 给我们提供了各种各样的功能.他帮助我们去 ...
- React.Component 和 React.PureComponent 、React.memo 的区别
一 结论 React.Component 是没有做任何渲染优化的,但凡调用this.setState 就会执行render的刷新操作. React.PureComponent 是继承自Componen ...
随机推荐
- UVA 10198 Counting
Counting The Problem Gustavo knows how to count, but he is now learning how write numbers. As he is ...
- Dalvik虚拟机Java堆创建过程分析
文章转载至罗升阳CSDN社区博客,原地址: http://blog.csdn.net/luoshengyang/article/details/6557518 近年来,手机移动平台越来越火爆.打开自己 ...
- sql 合并列
1.合并一列用“ ,”号隔开. 如下图: 这样的一列我想直接在sql里面合并最后变成:586,444,444,444,444这样的效果,平常的做法是直接把这列数据取出来,在前端循环加上逗号,但其实是可 ...
- Private Members in JavaScript
Private Members in JavaScript Douglas Crockford www.crockford.com JavaScript is the world's most mis ...
- poj2385 简单DP
J - 简单dp Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:65536KB 64bit ...
- GTD:是一种态度
时间管理发展的四个阶段: 第一代理论着重利用便条与备忘录,在忙碌中调配时间与精力: 第二代理论强调行事历与日程表,反映出时间管理已注意到规划未来的重要: 第三代理论正是目前流行的优先级观念.也就是依据 ...
- 遍历json的方式
var obj = eval("(" + data + ")"); for(var key in obj) { alert(obj[key]); }
- 解决Windows 7/win8 使用VMware虚拟机的NAT 不能上网
最近在学习linux系统,在使用debian6更新源的时候,发现Nat模式上网就是配置不了.而内外网可以ping通.所以很苦恼.最后终于解决了. 以下操作在VMware10下进行 1.首先要设置一下 ...
- 答:我们公司的ASP.NET 笔试题,你觉得难度如何
闲来无事,逛逛园子,发现有个面试题,觉得有意思.已自己的理解答来看看,不足之处,请多指教. 原文地址:http://www.cnblogs.com/leotsai/p/aspnet-tests-for ...
- Codeforces 582B Once Again
http://codeforces.com/contest/582/problem/B 题目大意:给出一个序列,是由一个长度为n的序列复制T次得到的,问最长非下降子序列的长度. 思路:我们建立一个n* ...