百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

react-extras

> 前端框架
开源

用于处理 React 的有用组件和实用程序

744 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

用于处理 React 的有用组件和实用程序

React-extras

用于处理 React 的有用组件和实用程序

安装

bash
npm install react-extras

使用方法

javascript
import React from 'react';
import {If} from 'react-extras';

const App = props => (
	
		

	
);

API

autoBind(self, options?)

自动将您的 React.Component 子类方法绑定到实例。请参阅 [autoBind.React() 文档`](https://github.com/sindresorhus/auto-bind#autobindreactself-options)。

classNames(…input)

条件性地将 CSS 类名连接在一起。

输入

类型: string | object 接受字符串和对象的组合。只包含具有真值的对象键。其他内容将被忽略。

javascript
import {classNames} from 'react-extras';

classNames('unicorn', 'rainbow');
//=> 'unicorn rainbow'

classNames({awesome: true, foo: false}, 'unicorn', {rainbow: false});
//=> 'awesome unicorn'

classNames('unicorn', null, undefined, 0, 1, {foo: null});
//=> 'unicorn'

const buttonType = 'main';
classNames({[`button-${buttonType}`]: true});
//=> 'button-main'
javascript
import {classNames} from 'react-extras';

const Button = props => {
	console.log(props);
	/*
	{
		type: 'success',
		isBlock: false,
		isSmall: true
	}
	*/

	const buttonClass = classNames(
		'button',
		{
			'button-block': props.isBlock,
			'button-small': props.isSmall
		}
	);

	console.log(buttonClass);
	//=> 'button button-success button-small'

	return …;
};

###`` 如果 condition 属性为 true,则 React 组件会渲染子元素。

请注意,即使在 condition 为 false 时不渲染子元素,它们仍然会被计算。如果您需要在 false 条件下不计算子元素,可以将一个函数传递给 render 属性,该函数返回子元素:

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScriptnpm-packagereactreact-componentreact-utils

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架