I'm new to react and trying to redo my personal site, I'm stuck here trying to use react-loading-skeleton. Here's my code:
constructor() {
super();
this.state = { isLoading: true }
}
componentDidMount() {
this.setState({ isLoading: false })
}
render() {
let button;
if (this.state.isLoading) {
button = 'Hi, there!';
} else {
button = <Skeleton />;
}
I want the text to load when the state is loaded
I think this will do your job:
state={
isLoading:true
}
componentDidMount(){
setInterval(() => {
this.setState({isLoading:false})
}, 1000);
}
render() {
return (
this.state.isLoading?(
<div>Loading...</div>
):(
<div>
Welcome
</div>
)
)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.