score:1
an example of how it can be done in react in this working repl.
import react from 'react';
import './app.css';
class app extends react.component {
constructor(props) {
super(props);
this.inputref = react.createref();
this.onbrowseclick = this.onbrowseclick.bind(this);
}
componentdidmount() {
}
onbrowseclick = () => {
this.inputref.current.click();
};
render() {
return (
<div>
<input type="file" style={{display: 'none'}} ref={this.inputref}></input>
<button onclick={this.onbrowseclick}>browse</button>
</div>
);
}
}
export default app;
Source: stackoverflow.com
Related Query
- Property addEventListener of null inside react page
- add raw HTML with <script> inside Gatsby React page
- Cannot read property 'refs' of null react error react js
- Uncaught TypeError: Cannot read property 'state' of null in react
- React component returning cannot read property '__reactInternalInstance$ of null after trying to access array
- React - Cannot read property 'setState' of null
- Cannot read property 'selectionEnd' of null using React + Jest + Datepicker + TextMask
- React: Accessing a page outside React app, inside public folder
- How to get over Cannot read property 'removeEventListener' of null in react
- TypeError: Cannot read property 'createEvent' of null React Apollo testing
- React Router v4 - Redirect to home on page reload inside application
- React - this.state is null inside render when getting data from API
- React tutorial: Uncaught TypeError: Cannot read property 'data' of null
- TypeError: Cannot read property 'value' of null in React Form
- this.state is null inside render React and Typescript
- React refs: Cannot read property 'focus' of null
- Cannot read property 'style' of null React
- addEventListener is null in React
- React JS and Google Spreadsheets: Cannot Read Property '2' of Null
- Render react component inside Blazor page
- TypeError: Cannot read property 'name' of null in react
- TypeError: Cannot read property 'substr' of null - React
- Heroku, NodeJs and React issue: SCRIPT5007: Unable to get property 'apply' of undefined or null reference
- TypeError: Cannot read property 'length' of null in React Project
- Cannot read property 'setState' of null react
- TypeError: Cannot read property 'foo' of null - Object, React
- Updating only one property inside an array of objects react
- cannot read property of null using state in react
- Can I use react component property inside PostCss style
- ReactJS : How to wrap knockoutJS page inside React component
More Query from same tag
- React and ApolloClient: Network error: forward(...).subscribe is not a function
- Modify image on div mouseover
- How to pass an object through url in .net core using httpget method?
- ReactCSSTransitionGroup animate table cells
- Fetching data keys from an api data set
- Cannot read properties of null (reading 'pulsate') in material-ui Button component
- How to load react component based on prop value
- Is there a way to import a CSS file according to media in ReactJS
- React : POST and GET not found
- React how to get wrapped component's height in HOC?
- Prevent React from re-rendering a specific child component
- How do I type-check this object in Typescript
- Bootstrap carousel: sets active item to first when data changes (Reactjs)
- Query Wordpress Posts by string with GraphQL
- Include a function & JSX in Conditionally Rendering
- react django rendering same content
- 'ref' declaration in pure react
- How to add <canvas> support to my tests in Jest?
- How to properly print values from a nested loop in a react render() method?
- Uncaught TypeError: repos.map is not a function
- how to display this data in react with map
- How to enable/disable elements from an array in React JS?
- How to remove ReactJS warning related to using a `value` prop to a form field without an `onChange` handler when the handler is actually defined?
- Property 'onClick' does not exist on type '{ children?: ReactNode; }'
- Updating the state of an array on React
- Responsive layout using Flexbox and Tachyons
- Reactjs: setState with checkbox: checked or unchecked
- React component receiveing props as undefined
- Yup / Formik validation using dynamic keys
- Import node_module plugin css to next js project