草庐IT

react-native-native-module

全部标签

javascript - React-Intl 如何从变量切换语言环境和消息

我正在尝试弄清楚如何使用React-Intl更改语言。这是我的第一个React应用程序,它是用create-react-app制作的,我没有使用Redux或Flux。在我的index.js中有以下代码:importReactfrom'react';importReactDOMfrom'react-dom';importTodoAppfrom'./components/TodoApp';importregisterServiceWorkerfrom'./registerServiceWorker';import'./index.css';//BootstrapCSSlibrariesim

javascript - 在 React 中创建滚动位置指示器

我正在尝试在React中编写滚动指示器进度条。我有它与Jquery一起工作,但想知道如何使用纯Javascript来完成它。componentDidMount(){window.addEventListener('scroll',this.handleScroll);}handleScroll(){varwinHeight=$(window).height(),docHeight=$(document).height(),value=$(window).scrollTop(),max,percent;max=docHeight-winHeight;percent=(value/max)

javascript - react native : How to set <TextInput/>'s height and width to <View/> container?

我目前有一个在里面有一个padding:15.我想要's覆盖内部所有空间的宽度和高度除了填充。所以我尝试了varwidth=Dimensions.get('window').width和以下,但是遵守左侧的填充,但当您继续键入时,它会超出右侧填充:那么我怎样才能让TextInput覆盖View内的所有空间、高度和宽度,同时还要遵守View的填充规则?谢谢 最佳答案 尝试将TextInput的样式设置为flex:1而不是获取宽度。Flex样式将自动填充您的View并将填充留空。 关于jav

javascript - 在 React 中遍历 JSON

我有以下代码:exportclassHighlightsextendsReact.Component{render(){return({JSON.stringify(this.props.highlights_data.data)})}}这会打印出以下内容:{"active":{"label":"Active","value":"12"},"automatic":{"label":"Automatic","value":"8"},"waiting":{"label":"Waiting","value":"1"},"manual":{"label":"Manual","value":"3

javascript - 如何在 React 中使用带钩子(Hook)的生命周期方法?

我已经了解了Reactv16.7.0中引入的钩子(Hook)。https://reactjs.org/docs/hooks-intro.html所以我对钩子(Hook)的理解是我们可以在功能组件中使用状态而不用在React中编写类组件。这真是一个了不起的功能。但我不清楚在功能组件中使用钩子(Hook)。import{useState}from'react';functionExample(){const[count,setCount]=useState(0);return(Youclicked{count}timessetCount(count+1)}>Clickme);}如果使用了钩

javascript - 在哪里可以找到 javascript native 函数源代码?

这个问题在这里已经有了答案:HowcanIseethesourceofbuilt-inJavaScriptfunctions?[closed](1个回答)关闭6年前。哪里可以找到原生js函数的源码,比如我想看eval()函数

javascript - jshint 错误 : Cannot find module 'underscore'

我的grunt任务似乎运行得非常好,但每次运行它时我都会收到此错误:Loading"jshint.js"tasks...ERROR>>Error:Cannotfindmodule'underscore'有什么办法可以找出为什么会这样吗?我可以看到/grunt-contrib-jshint目录位于/node_modules目录中。有什么原因找不到underscore模块吗?我试过运行npminstall但在运行grunt时我仍然遇到同样的错误。有什么想法吗?感谢您的帮助。 最佳答案 当您遇到找不到模块x错误时,有时可能会有所帮助的一件

javascript - react native v0.56 : Cannot read property 'filename' of undefined at PluginPass. JSXOpeningElement

我刚刚将ReactNative从0.55更新到0.56。但是,当我尝试运行代码(react-nativerun-android或run-ios)时,捆绑停止到这一点:Loadingdependencygraph,done.error:bundlingfailed:TypeError:Cannotreadproperty'filename'ofundefinedatPluginPass.JSXOpeningElement({path_to_my_project}/react-native/node_modules/babel-plugin-transform-react-jsx-sour

javascript - Prop 未定义 React js

我正在使用Reactjs,但我不知道为什么我得到的Prop未定义。这是我的类(class)。importReact,{Component}from'react';constInputHeight={height:'50px',}functionclearData(){this.refs.input.value="";}exportdefaultclassTextInputextendsComponent{render(){return();}}TextInput.propTypes={inputType:React.PropTypes.oneOf(['text','number','e

javascript - react 导出意外 token

所以我有这些文件和文件夹。App.jsmodules/user/index.jslist.js在list.js中我有exportdefault(props)=>(...)在index.js中,我有exportUserListfrom'./list';在App.js中,我有import{UserList}from'./modules/user';那里有什么问题吗?因为我得到了./src/modules/user/index.jsSyntaxerror:Unexpectedtoken,expected{(1:7)>1|exportUserListfrom'./list';但我不明白这里有什