说,我有一个组件,它在扩展组件的渲染功能中。
因为只有一个渲染函数会调用,如果我从“面板”中删除该函数,它将在“ ExtendedComponent”上运行,这是它们的其他方式。所以只有通过功能我才能从“ ExtendedComponent”中渲染“ SomeComponent”
class ExtendedComponent extends React.Component {
constructor(props) {
super(props);
this. state = {
showComponent: false,
};
}
render() {
console.log(this.state);
const {showComponent} = this.state;
return showComponent ? (
<SomeComponent content="Message sent" />) : null;
}
toggleComponent = () => {
console.log("came here");
this.setState(({showComponent}) => ({showComponent: !showComponent}));
};
}
class Panel extends ExtendedComponent {
componentDidMount() {
this.toggleToast();
}
render() {
return (
<div>
<h1>Hey!!!!!</h1>
</div>
);
}
}
答案 0 :(得分:0)
有两种方法可以呈现超级组件而不是子组件:
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:529)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:123)
... 62 more
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1319)
at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525)
... 64 more
第二种适用于您的情况,因为它可以动态工作。
super.render();