This is baffling me, even after reading the TS error.
Error: TS2322: Type Question is not assignable to type ReactNode
export default class TeamProfile extends Component<{ company: Organization }> {
render() {
const { company } = this.props;
const { teamProfile } = company.interview;
return (
<div className="all-100">
<p className="section-heading bold font-22" id="ft-team-profile">
Team Profile
</p>
<div className="all-100 padding-left-30 align-left">
{teamProfile.teamContext.answer && (
<div className="all-100 align-left padding-bottom-10">
<span className="bold blue">{teamProfile.teamContext.question}</span>
<TeamContextAnswer answer={teamProfile.teamContext.answer} className="ft-answer" />
</div>
)}
</div>
</div>
);
}
}
export interface TeamProfile {
teamContext: {
question: Question;
answer: Array<string>;
};
}
export interface Question {
question: string;
answer: Array<string>;
details: Array<string>;
description: string;
}
2
Answers
teamProfile.teamContext.question
isn’t a string or a<SomeComponent />
that react knows how to turn into something displayable. You can explicitly wrap it in JSON.stringify to see what you’ve got there instead.<span>{JSON.stringify(teamProfile.teamContext.question)}</span>
See the type definition of
ReactNode
:teamProfile.teamContext.question
is aQuestion
type that is not compatible withReactNode
You should use