reactjs - react-loading-skeleton 继续加载
问题描述
我是新来的反应并试图重做我的个人网站,我被困在这里试图使用 react-loading-skeleton。这是我的代码:
constructor() {
super();
this.state = { isLoading: true }
}
componentDidMount() {
this.setState({ isLoading: false })
}
render() {
let button;
if (this.state.isLoading) {
button = 'Hi, there!';
} else {
button = <Skeleton />;
}
我希望在加载状态时加载文本
解决方案
我认为这会做你的工作:
state={
isLoading:true
}
componentDidMount(){
setInterval(() => {
this.setState({isLoading:false})
}, 1000);
}
render() {
return (
this.state.isLoading?(
<div>Loading...</div>
):(
<div>
Welcome
</div>
)
)
}
推荐阅读
- rabbitmq - 使用 CELERY 消费者时 Rabbitmq 中的高消息准备就绪
- python-3.x - 收到此错误: (psycopg2.errors.NumericValueOutOfRange) 整数超出范围但未插入 Bigint
- celery - 带有 AWS SQS 队列的 Celery 突然无法连接
- python-3.x - 为什么 np.std() 和 pivot_table(aggfunc=np.std) 返回不同的结果
- mysql - mysql 权限无法正常工作
- webrtc - 如何使用 simpleWebRTC SDK 增加 channelMessage 最大大小
- python - 动画改变点之间的线条数量 - Python
- javascript - 有没有办法在表的一个字段中插入多个数据,并且一个特定的数据在其字段上具有不同的值?代码点火器
- reactjs - next.js 链接如何避免服务器请求?
- haskell - 感应提升