我使用以下方法创建一个新的react-native项目:
react-native init {proj_name}
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误.
D:\Reactnative\Project\{proj_name}\node_modules\react-native\local-cli\cliEntry.js:30
import type {CommandT} from './commands';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:607:28)
at Module._compile (D:\Reactnative\Project\Learnwizz\node_modules\pirates\lib\index.js:91:24)
at Module._extensions..js (module.js:654:10)
at Object.newLoader [as .js] (D:\Reactnative\Project\Learnwizz\node_modules\pirates\lib\index.js:96:7)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
Run Code Online (Sandbox Code Playgroud) I have a flatlist showing videos. I want that when a video goes out of the view it should be paused. I am maintaining the pause state in each of the Posts component.
class Posts extends React.PureComponent {
constructor() {
super()
this.state = {
pause: true,
}
return(){
<Video
pause={this.state.pause}
//other props
/>
}
}
Run Code Online (Sandbox Code Playgroud)
I am using react-native-video.
我已经尝试使用onViewableItemsChangedof的道具,Flatlist但是它不会改变状态。
我试过了。但这似乎对我不起作用。
我应该如何进行?
在使用numpy分隔x_values和y_values时导入文件后:
import pandas as pd
from sklearn import linear_model
from matplotlib import pyplot
import numpy as np
#read data
dataframe = pd.read_csv('challenge_dataset.txt')
dataframe.columns=['Brain','Body']
x_values=np.array(dataframe['Brain'],dtype=np.float64).reshape(1,-1)
y_values=np.array(dataframe['Body'],dtype=np.float64).reshape(1,-1)
#train model on data
body_reg = linear_model.LinearRegression()
body_reg.fit(x_values, y_values)
prediction=body_reg.predict(x_values)
print(prediction)
#visualize results
pyplot.scatter(x_values, y_values)
pyplot.plot(x_values,prediction)
pyplot.show()
Run Code Online (Sandbox Code Playgroud)
我将绘图作为下图,它没有显示最佳拟合线,当我打印'预测'的值时,它显示的值与'y_values'相同.
#read data
dataframe = pd.read_csv('challenge_dataset.txt')
dataframe.columns=['Brain','Body']
x_values=dataframe[['Brain']]
y_values=dataframe[['Body']]
Run Code Online (Sandbox Code Playgroud)
为什么会这样?
提前致谢.
当我从根文件夹中使用命令时,我想检查我在项目中使用的react native版本:
D:\Reactnative\Albums>npm view react-native version
0.56.0
Run Code Online (Sandbox Code Playgroud)
版本是0.56.0,不是我已安装的版本,但安装在:
D:\Reactnative\Albums>react-native -v
react-native-cli: 2.0.1
react-native: 0.55.4
Run Code Online (Sandbox Code Playgroud)
这里提到的版本是0.55.4,这是正确的。那么为什么会发生这种冲突呢?