score:0
Technically, you could use any standard HTML element, so for generic ones, I don't think there's anything better than <div />
and <span />
....
// loading is some prop
if (loading) {
return <span testID='loading'>loading</span>;
}
score:1
You cannot pass props to a React fragment, it is mentioned in the docs.
Does a View
not work for your use-case?
if (loading) {
return <View testID='loading'>loading</View>;
}
Source: stackoverflow.com
Related Query
- Functions are not valid as a React child. This may happen if you return a Component instead of from render
- Return DOM element in render function of React component
- Typescript with React - use HOC on a generic component class
- How to create a generic React component with a typed context provider?
- How do you correctly use React.lazy() in Typescript to import a react component with a generic type parameter?
- loop in return statement of a component in react js
- Is there a way to return React Component as string instead of object?
- React - Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render
- Generic React TypeScript component with 'as' prop (able to render any valid dom node)
- react - conditional rendering inside component return function
- How to form a TypeScript rule/config that errors if I don't return a JSX in React Functional Component
- Inferred Generic Type on React Component
- Typescript: type inference for children on generic react component
- FlowType - Infer Generic Type on React Component
- React Hooks return children wrapping component
- Why does this React component return the string '0'
- if/else statement to return react component
- Is it possible to create a generic React list component with typescript?
- test with enzyme a react component with context: return an empty object
- React TS Generic component to pass generic props to children
- React How to return div and variable value for another component
- Use Generic flow types in React component Props and instantiate generic component>
- What does the second parameter in the generic argument of a Typescript-based React component stand for?
- Getting React component instance from ReactDOM.render() return
- React - Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render
- How to make a functional React component with generic type?
- How to return text input into React component
- Variable number of generic arguments for React component in Typescript
- Warning: Functions are not valid as a React child.This may happen if you return a Component instead of <Component /> from render
- Attempt to build a generic form component in React without using eval()
More Query from same tag
- Load an array with react.js
- setInterval callback function is not dynamic (Redux props)
- How do we use two themes on the same DOM element when using a ThemeProvider?
- Unit testing Apollo Graphql in React using Hooks
- How to start React JS application in background mode on linux?
- Making state updates more readable in React
- How to add a prop to a child component already receiving props via the spread operator?
- React Redux append components
- Material UI Autocomplete displays "No Options" when using async data
- Apply Inline Color within Div Tag Typescript React
- JSDocs (better docs) 'NODE_ENV' is not recognized as an internal or external command, operable program or batch file
- useEffect not running on refresh
- Module not found: Can't resolve 'moment' in 'node_modules\react-moment\dist' in reactjs
- React Native alignSelf center and stretch to maxWidth?
- With React ErrorBoundary, I want to reset hasError from an internal function
- React Formik Material UI Autocomplete: How can I populate value inside of autocomplete from localStorage?
- React handleSubmit form - how to ensure that methods within the handlesubmit method will only be executed when a condition is satisfied
- react state is one state behind button clicks
- Is it possible to extend JSX / React to allow for custom directives?
- How to do setState on empty object inside state?
- Populating data on a table in React
- How to display an image from an array of images in react
- Typescript: How to add property ‘types’ to function returned from React.forwardRef
- How to create a setState wrapper that accepts arbitrary objects
- Reactjs: How to make all row checkbox checked true when material table is loaded and deselect when clicked and vice versa?
- how to use if-else inside the map return react js
- Why is my state update overwriting existing data values?
- Could anybody please help me to rewrite this code using useEffect()?
- What is this method carrying out in React.js?
- How to compare dates with tenary and && operator in React.js