use typescript
This commit is contained in:
40
src/components/SetTitle.tsx
Normal file
40
src/components/SetTitle.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
// import React from 'react';
|
||||
|
||||
// todo fix this mess
|
||||
|
||||
// const _callSetTitle = (props) => {
|
||||
// if (typeof props.onSetTitle === 'function' && props.title) {
|
||||
// props.onSetTitle(props.title);
|
||||
// }
|
||||
// };
|
||||
|
||||
// class _SetTitle extends React.Component {
|
||||
// constructor(props) {
|
||||
// super(props);
|
||||
// _callSetTitle(props);
|
||||
// }
|
||||
|
||||
// componentWillReceiveProps(nextProps) {
|
||||
// if (nextProps.title !== this.props.title) {
|
||||
// _callSetTitle(nextProps);
|
||||
// }
|
||||
// }
|
||||
|
||||
// render() {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
type SetTitleProps = {
|
||||
title: string
|
||||
onSetTitle?: (title: string) => void
|
||||
}
|
||||
|
||||
export default function SetTitle({title, onSetTitle}: SetTitleProps) {
|
||||
if (onSetTitle) {
|
||||
onSetTitle(title)
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user