export class App extends Component<{}> {
this.myRef = React.createRef();
constructor(props: {}) {/* ... */}
protected refreshItems() {
// Тут надо как-то вызвать метод refresh() у дочерних RandomString
if(this.myRef&&this.myRef.current&&this.myRef.current.refresh){
this.myRef.current. refresh()
}
}
render(): ReactNode {
return (
<div>
<RandomString this.myRef = React.createRef(); />
<RefreshButton onClick={this.refreshItems} />
</div>
);
}
}
import React from 'react';
class ShowWindowDimensions extends React.Component {
state = { width: 0, height: 0 };
render() {
return <span>Window size: {this.state.width} x {this.state.height}</span>;
}
updateDimensions = () => {
this.setState({ width: window.innerWidth, height: window.innerHeight });
};
componentDidMount() {
window.addEventListener('resize', this.updateDimensions);
}
componentWillUnmount() {
window.removeEventListener('resize', this.updateDimensions);
}
}
this.props.history.push({
state: { detail: response.data }
})
Our custom Firebase token will expire in 3600 seconds (1 hour). This is only half as long as our default Auth0 access token lifetime (which is 7200 seconds, or 2 hours).
var user = firebase.auth().currentUser;
var name, email, photoUrl, uid, emailVerified;
if (user != null) {
name = user.displayName;
email = user.email;
photoUrl = user.photoURL;
emailVerified = user.emailVerified;
uid = user.uid; // The user's ID, unique to the Firebase project. Do NOT use
// this value to authenticate with your backend server, if
// you have one. Use User.getToken() instead.
}
handleClick = function() {
this.setState(function (state) {
return {
isActive: !state.isActive
};
});
};
this.handleClick=this.handleClick.bind()
_getPostcards () {
try {
this.setState({isFecth:true})
const url = domain + '?app_id='+ app_id +'&category='+ category +'&page=' + this.state.page
return fetch(url)
.then((response) => response.json())
.then((responseJson) => {
console.log(responseJson)
this.setState({ data: responseJson.photos, pageMax: responseJson.pages })
this.setState({isFecth:false}) //<--------
})
.catch((error) =>{
console.error(error);
this.setState({isFecth:false}) //<--------
});
} catch (e) {
throw e
this.setState({isFecth:false}) //<--------
}
}