我已经创建了一个基于Material-UI 的 Button 组件的自定义按钮组件,所以我可以在一个动作挂起时覆盖一个加载圆圈。但是,React 抱怨以下内容:
警告:收到false非布尔属性loading。如果要将其写入 DOM,请改为传递字符串:loading="false" 或 loading={value.toString()}。
这是我的组件的样子。提前致谢!
import * as React from 'react'
import { ButtonProps } from '@material-ui/core/Button'
import { Button, CircularProgress } from '@material-ui/core'
interface IProps extends ButtonProps {
loading: boolean
}
export const LoadingButton = (props: IProps) => {
const { disabled, loading } = props
return (
<div className='button-container'>
<Button {...props} disabled={disabled == true || loading == true}/>
{loading == true && (
<CircularProgress size={24} className='button-progress' /> …Run Code Online (Sandbox Code Playgroud) 我正在尝试检查属于特定键的 JSON 值的实际数据类型。
test.json
{
"id": 50,
"name": "Joe"
}
Run Code Online (Sandbox Code Playgroud)
我想要类似的东西:
$ `jq 'typeof("id")' < test.json`
(output)>> string
Run Code Online (Sandbox Code Playgroud)
这可以使用jq吗?
我有一个需要获取 DOM 元素大小的类。它运行良好,但是当我调整窗口大小时,它不会更新,直到我更改应用程序中的状态,强制重新渲染。我已经尝试添加this.forceUpdate一个'resize'事件监听器componentDidMount(),但没有奏效。也许我做错了什么?理想情况下,我this.forceUpdate无论如何都想避免使用性能影响。任何解决方法?提前致谢!
我的代码:
class MyComponent extends React.Component {
state = { x: 0, y: 0 }
refCallback = (element) => {
if (!element) {
return
}
const { x, y } = element.getBoundingClientRect()
this.setState({ x, y })
}
render() {
console.log('STATE:', this.state) // Outputs the correct x and y values.
return (
<div ref={this.refCallback}>
<button>Hello world</button>
</div>
)
}
}
Run Code Online (Sandbox Code Playgroud) 假设我有一个food查询的表SELECT name FROM food ORDER BY name:
| name
|--------
| Apple
| Banana
| Carrot
| Donut
...
Run Code Online (Sandbox Code Playgroud)
我希望指定我选择的特定项目(如果在表中)固定在顶部(例如,“柠檬”然后是“胡萝卜”)。像这样:
| name
| -------
| Lemon
| Carrot
| Apple
| Banana
| Donut
...
Run Code Online (Sandbox Code Playgroud)
我可以使用哪种SQL查询来进行这种特定排序?