【发布时间】:2019-06-04 17:49:39
【问题描述】:
我正在尝试将 react 粘性标题添加到我的步进器。
但问题是,如果我在 App.js 中添加它不会呈现。
- 于是我开始调试 App.js 代码。
- 如果我在 App.js 的渲染方法中提供控制台,它不会显示 console.log("App---->");
- 现在我收到无法读取未定义错误的属性“getState”
- 你能告诉我如何解决它吗?
- 以便将来我自己修复它。
- 在下面提供我的代码 sn-p 和沙箱
https://codesandbox.io/s/6zv5n0ro9z
App.js
import React from "react";
import { StickyContainer, Sticky } from "react-sticky";
// ...
class App extends React.Component {
render() {
console.log("App---->");
return (
<StickyContainer>
{/* Other elements can be in between `StickyContainer` and `Sticky`,
but certain styles can break the positioning logic used. */}
<Sticky>
{({
style,
// the following are also available but unused in this example
isSticky,
wasSticky,
distanceFromTop,
distanceFromBottom,
calculatedHeight
}) => <header style={style}>{/* ... */}</header>}
</Sticky>
{/* ... */}
</StickyContainer>
);
}
}
index.js
import React from "react";
//import ReactDOM from "react-dom";
import Demo from "./demo";
import App from "./components/App";
import { render } from "react-dom";
import { logger } from "redux-logger";
import { Provider } from "react-redux";
import { createStore, applyMiddleware } from "redux";
//import reducer from "./reducers";
import thunk from "redux-thunk";
//const store = createStore(reducer, applyMiddleware(thunk, logger));
//ReactDOM.render(<Demo />, document.querySelector("#root"));
render(
// <Provider store={store}>
<Provider>
<App />
</Provider>,
document.getElementById("root")
);
【问题讨论】:
标签: javascript html reactjs redux material-ui