有什么方法可以让我的Node.js应用程序与Microsoft SQL通信?我没有在野外看到任何MS SQL驱动程序?
我将一个非常简单的应用程序放在一起,需要能够与现有的MS SQL数据库进行通信(否则我会使用mongoDB或Redis)
我刚刚意识到,对于Grails控制器,还有另一种渲染方法"响应".
如果我们想在控制器中渲染视图,则response和render方法之间有什么区别.
我想在我的React Native应用程序中使用Picker组件,但它占用了太多的屏幕高度.有没有办法让选择器限制自己一次只显示两个项目,然后可以在其中滚动?
我是Java脚本的新手.我看到许多地方返回并渲染被使用只是想知道它们之间的区别.
所以我有一个React组件来获取数据componentDidMount()
.该组件路由可以采用查询字符串来确定要加载哪个资源(即资源的id , /some/where?resource=123
.
当我更改查询字符串中的id并在浏览器中按Enter时,组件不会重新装入,而是保持不变.因此,没有加载资源654的数据.
为了解决这个问题,我可以将componentDidMount的代码复制并粘贴到其中componentDidUpdate()
,如果查询字符串已更改,则再次获取数据.
代码示例
componentDidMount() {
const { resource } = this.props.location.query;
if (resource) {
this.fetchData();
// where fetch data is a function that makes calls
// to an API and updates the Redux state
}
}
componentDidUpdate(prevProps, prevState) {
const { resource } = this.props.location.query;
if (resource && resource !== prevProps.location.query.resource) {
this.fetchData();
}
}
Run Code Online (Sandbox Code Playgroud)
但有没有更好的方法来处理这个?
我有以下代码,我正在打电话ReactDOM.hydrate
.这是共享代码,有时会从节点服务器调用,有时也会在客户端浏览器中调用.hydrate
在客户端上调用它时,是否需要执行任何不同的操作(然后调用).通常,我打电话render
.
const render = Component => {
ReactDOM.hydrate(
<Router history={browserHistory}>
<FullPage />
</Router>,
document.getElementById('root')
)
}
Run Code Online (Sandbox Code Playgroud)
渲染(应用程序);
我经常使用npm模块json-server
在给定db.json
文件的情况下生成伪造的JSON api 。有什么办法可以将其部署到Heroku?本质上,我只是跑步
json-server --watch db.json
Run Code Online (Sandbox Code Playgroud)
并且它运行一台服务器,如果public/
目录中有任何内容,该服务器也将处理静态html 。本质上,我认为它只是在运行Node服务器,除了我尝试推送到Heroku之外,但是没有用。为了使Heroku json-server
作为服务器运行该模块,我应该执行一个特殊的过程吗?
我一直在使用React状态来维护一些数据.对于整数和字符串它运行良好,但遗憾的是数组不起作用.
在我的组件构造函数中,我有
constructor(props) {
super(props);
this.state = {
terms: 5,
myArray: []
}
Run Code Online (Sandbox Code Playgroud)
然后,我试图在componentDidUpdate中维护它
componentDidUpdate() {
this.state = {
terms: this.state.terms,
myArray: this.state.myArray
}
Run Code Online (Sandbox Code Playgroud)
但是myArray: this.state.myArray
没有用.但是terms: this.state.terms
工作得很好.
有人可以帮忙!
现在我使用ReduxForm的Field组件并应用原始语义UI类.但后来我遇到了Semantic UI React,它使事情变得更容易 - 你可以使用具有语义ui风格的React组件.
您如何将ReduxForm与SemanticUIReact集成?
例如,我目前有类似的东西:
<Field name="gender" component="select" className="ui fluid dropdown">
{genderOptions}
</Field>
Run Code Online (Sandbox Code Playgroud)
但是,我想将下面的语义UI React组件连接到redux-form:
<Form.Field control={Select} label='Gender' options={genderOptions} placeholder='Gender' />
Run Code Online (Sandbox Code Playgroud)
!注意Field来自redux-form,Form.Field来自语义-ui-react
我正在查看DatePickerIOS组件的文档,他们使用getDefaultProps()来初始化组件中的props.
getDefaultProps: function () {
return {
date: new Date(),
timeZoneOffsetInHours: (-1) * (new Date()).getTimezoneOffset() / 60,
};
},
getInitialState: function() {
return {
date: this.props.date,
timeZoneOffsetInHours: this.props.timeZoneOffsetInHours,
};
},
Run Code Online (Sandbox Code Playgroud)
使用ES6语法的等价物是什么?因为我一直在使用:
constructor(props) {
super(props);
this.state = {
//equivalent to getInitialState is here
};
}
Run Code Online (Sandbox Code Playgroud)
我应该这样做.props = {}来设置我的默认道具?
reactjs ×4
javascript ×3
react-native ×2
fetch ×1
grails ×1
heroku ×1
json-server ×1
lifecycle ×1
node-mssql ×1
node.js ×1
picker ×1
react-redux ×1
react-router ×1
redux-form ×1
semantic-ui ×1
sql-server ×1
styles ×1
tedious ×1