score:1
Accepted answer
the best way to do this is by cloning the element, you should use react.cloneelement. to make the component usable everywhere, just create a new component using it, and export it.
import react from "react";
import {link} from "react-router";
const customlinkattribute = react.cloneelement(link, {
newprop: "new prop val here"
});
export default customlinkattribute;
score:1
you can clone the element and add the extra props using react.cloneelement
e.g:
var clonedelementwithextraprops = react.cloneelement(
mainelement,
{ newprop: "this is a new prop" }
);
return clonedelementwithextraprops;
Source: stackoverflow.com
Related Query
- How do I extend React components already in use?
- How to use SCSS variables into my React components
- How to use react j s components in react native app?
- How to use redux-toolkit createSlice with React class components
- How to use Media Queries inside a React Styled Components Keyframe?
- How to use react components from other files
- how to import data in react from a js file to use in components
- How can I use React Material UI's transition components to animate adding an item to a list?
- How to use this.props in React Styled Components
- How to use the updated value in redux store immediately after the action is dispatched in react js functional components
- How to use inheritance with React components and es6 classes
- How to Use AWS Amplify react components anywhere in an application
- How to use router for switching between components with a key value pair in react
- How to use React BluePrint components with TypeScript?
- How to use styled components in React in order to get keyframe animations
- How to use React components as part of legacy HTML/JS app?
- How to use React for individual site components
- How to use React + TypeScript to render components by looping through an array?
- How to switch between desktop and mobile version if I use React MediaQuery components
- how to use destructuring in react components
- React - how to extend a component that has child components and keep them?
- How to use the useHook in the component rather than passing the value returned from it as a prop to the components using react and typescript?
- React | Npm package - How can I export 2 components for use as an npm package
- How to use react components in blaze?
- How use react components from npm in rails
- How can I create a counter as components to use multiple times and create one button to reset all the counter in React JS?
- How to use async await in React components without useEffect
- How to add listener on change Object which already defined with @observable decorator in MobX to use in React
- How to properly use refs in React functional components
- How do i use different css files for different components React with same class names
More Query from same tag
- Cannot center navbar and logo with tailwind
- How to layout with nine square view in React Native?
- React router 4 url issue
- React typescript useParams() always returns undefined in useEffect
- Material-ui is not working as intended
- problem connecting multiple container components to redux store
- Index signature in React props
- access the data of a hook- React
- Jest code coverage with wildcard path
- React-router: Passing props to children
- How do i change React Google Charts background color?
- Error when trying to use the result of a function, typeError: Cannot read property 'map' of undefined in React
- How to clear textarea on click enter in React?
- How to toggle item by id or index ? React.js
- Issue with using canvas in React
- How can we receive a csv file in server side react hooks web app
- The following Code is not working in react.js
- React and SetInterval (FCC Pomodoro Timer..)
- Which is faster and performant: useState or useReducer?
- multiple react apps (components) on the same page?
- In JSX | React How can the prop be passed to the button state so the button state can load a new page?
- Add delay into a map with React Hooks
- How to create a drop down in React?
- Is is possible to access a React component inside an array map function using ref?
- TypeError: Cannot read property 'map' of undefined in react component
- Undefined Props in React
- Update data in parent when added in child in react
- React with typescript - type safety with setState
- Use context to share content after socket connection in React
- Troubles with React.useState()