or <> fragment."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"Using too many elements in JSX","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"Using JavaScript functions inside JSX","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"Not using semicolons properly","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"Not wrapping JSX elements inside a parent element","comment":{"@type":"Comment","text":"JSX requires all elements to be wrapped in a single parent element such as or <> fragment."},"answerExplanation":{"@type":"Comment","text":"JSX requires all elements to be wrapped in a single parent element such as or <> fragment."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"What is the preferred way to style components in React Native?","comment":{"@type":"Comment","text":"React Native does not support external CSS files. Instead, styles are defined using the StyleSheet API."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"Using inline styles","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"Using external CSS files","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"Using Bootstrap","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"Using the StyleSheet API","comment":{"@type":"Comment","text":"React Native does not support external CSS files. Instead, styles are defined using the StyleSheet API."},"answerExplanation":{"@type":"Comment","text":"React Native does not support external CSS files. Instead, styles are defined using the StyleSheet API."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"What does Flexbox in React Native help with?","comment":{"@type":"Comment","text":"Flexbox is used in React Native for arranging components efficiently on the screen."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"Handling animations","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"Writing JavaScript logic","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"Adding event handlers","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"Managing UI layout and alignment","comment":{"@type":"Comment","text":"Flexbox is used in React Native for arranging components efficiently on the screen."},"answerExplanation":{"@type":"Comment","text":"Flexbox is used in React Native for arranging components efficiently on the screen."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"What is the default flex direction in React Native?","comment":{"@type":"Comment","text":"Unlike web development where row is the default, React Native's default flex direction is column."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"row","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"row-reverse","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"column-reverse","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"column","comment":{"@type":"Comment","text":"Unlike web development where row is the default, React Native's default flex direction is column."},"answerExplanation":{"@type":"Comment","text":"Unlike web development where row is the default, React Native's default flex direction is column."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"Which of the following properties is used to create a responsive layout in React Native?","comment":{"@type":"Comment","text":"The flex property allows components to expand and adjust to available space dynamically."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"position","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"display","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"overflow","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"flex","comment":{"@type":"Comment","text":"The flex property allows components to expand and adjust to available space dynamically."},"answerExplanation":{"@type":"Comment","text":"The flex property allows components to expand and adjust to available space dynamically."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"What does justifyContent: 'center' do in React Native styling?","comment":{"@type":"Comment","text":"justifyContent controls the alignment of children along the main axis (vertical by default in React Native)."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"Aligns items horizontally in the center","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"Centers items inside a View","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"Removes extra spacing between elements","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"Aligns items vertically in the center","comment":{"@type":"Comment","text":"justifyContent controls the alignment of children along the main axis (vertical by default in React Native)."},"answerExplanation":{"@type":"Comment","text":"justifyContent controls the alignment of children along the main axis (vertical by default in React Native)."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"How do you apply multiple styles to a component in React Native?","comment":{"@type":"Comment","text":"In React Native, multiple styles can be applied using an array of style objects, e.g., style={[styles.primary, styles.secondary]}."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"Use multiple style attributes","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"Separate styles with commas","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"Use CSS classes","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"Pass an array of style objects","comment":{"@type":"Comment","text":"In React Native, multiple styles can be applied using an array of style objects, e.g., style={[styles.primary, styles.secondary]}."},"answerExplanation":{"@type":"Comment","text":"In React Native, multiple styles can be applied using an array of style objects, e.g., style={[styles.primary, styles.secondary]}."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"What is the correct way to define styles using StyleSheet.create?","comment":{"@type":"Comment","text":"The correct syntax for defining styles in React Native is StyleSheet.create({ ... })."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"StyleSheet({ myStyle: { color: 'blue' } })","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"Style.create({ myStyle: { color: 'blue' } })","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"new StyleSheet({ myStyle: { color: 'blue' } })","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"StyleSheet.create({ myStyle: { color: 'blue' } })","comment":{"@type":"Comment","text":"The correct syntax for defining styles in React Native is StyleSheet.create({ ... })."},"answerExplanation":{"@type":"Comment","text":"The correct syntax for defining styles in React Native is StyleSheet.create({ ... })."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"What will be the background color of a View with the following style: { backgroundColor: 'transparent' }?","comment":{"@type":"Comment","text":"The backgroundColor: 'transparent' property makes the View's background invisible, showing the parent background."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"White","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"Black","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"Gray","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"Transparent","comment":{"@type":"Comment","text":"The backgroundColor: 'transparent' property makes the View's background invisible, showing the parent background."},"answerExplanation":{"@type":"Comment","text":"The backgroundColor: 'transparent' property makes the View's background invisible, showing the parent background."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"What will happen if you set flex: 1 to a View inside a parent with flex: 1?","comment":{"@type":"Comment","text":"When a child View inside a flex: 1 parent also has flex: 1, it shares equal space with other flex: 1 children."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"The child View will occupy the entire screen","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"The child View will be hidden","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"It will throw an error","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"The child View will divide space equally with siblings","comment":{"@type":"Comment","text":"When a child View inside a flex: 1 parent also has flex: 1, it shares equal space with other flex: 1 children."},"answerExplanation":{"@type":"Comment","text":"When a child View inside a flex: 1 parent also has flex: 1, it shares equal space with other flex: 1 children."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"Why is the error \"StyleSheet.create is not a function\" occurring?","comment":{"@type":"Comment","text":"StyleSheet must be correctly imported from react-native using import { StyleSheet } from 'react-native';."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"StyleSheet is not supported in React Native","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"Incorrect function name","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"Styles must be defined inside the component","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"Incorrect import of StyleSheet","comment":{"@type":"Comment","text":"StyleSheet must be correctly imported from react-native using import { StyleSheet } from 'react-native';."},"answerExplanation":{"@type":"Comment","text":"StyleSheet must be correctly imported from react-native using import { StyleSheet } from 'react-native';."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"What could be the reason for styles not applying to a component?","comment":{"@type":"Comment","text":"Styles in React Native should be applied using a style prop with a valid style object."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"CSS classes are required","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"Only inline styles are supported","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"React Native does not support styling","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"Style object is not used","comment":{"@type":"Comment","text":"Styles in React Native should be applied using a style prop with a valid style object."},"answerExplanation":{"@type":"Comment","text":"Styles in React Native should be applied using a style prop with a valid style object."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"Why does alignItems: 'center' not work as expected on a View?","comment":{"@type":"Comment","text":"alignItems works in conjunction with flex, so the parent container must have flex set for proper alignment."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"alignItems does not exist in React Native","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"It only works if justifyContent is also used","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"It only works on Text components","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"It requires a parent with flex applied","comment":{"@type":"Comment","text":"alignItems works in conjunction with flex, so the parent container must have flex set for proper alignment."},"answerExplanation":{"@type":"Comment","text":"alignItems works in conjunction with flex, so the parent container must have flex set for proper alignment."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"What is the purpose of state in React Native?","comment":{"@type":"Comment","text":"State is used to manage dynamic data within a component in React Native."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"To manage navigation","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"To handle API calls","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"To define styles","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"To store local component data","comment":{"@type":"Comment","text":"State is used to manage dynamic data within a component in React Native."},"answerExplanation":{"@type":"Comment","text":"State is used to manage dynamic data within a component in React Native."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"How is state defined in a functional component?","comment":{"@type":"Comment","text":"The useState hook is used in functional components to manage state in React Native."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"this.state","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"setState","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"componentState","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"useState hook","comment":{"@type":"Comment","text":"The useState hook is used in functional components to manage state in React Native."},"answerExplanation":{"@type":"Comment","text":"The useState hook is used in functional components to manage state in React Native."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"What is the key difference between state and props?","comment":{"@type":"Comment","text":"Props allow data to be passed from parent to child, while state is component-specific and can change dynamically."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"Props are mutable, but state is immutable","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"Props can be changed inside the component","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"State and props are identical","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"State is managed inside the component, while props are passed from a parent","comment":{"@type":"Comment","text":"Props allow data to be passed from parent to child, while state is component-specific and can change dynamically."},"answerExplanation":{"@type":"Comment","text":"Props allow data to be passed from parent to child, while state is component-specific and can change dynamically."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"What happens when state changes in a component?","comment":{"@type":"Comment","text":"When state changes, React Native triggers a re-render of the component to reflect the updated data."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"Nothing happens","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"State is reset to the initial value","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"The app crashes","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"The component is re-rendered","comment":{"@type":"Comment","text":"When state changes, React Native triggers a re-render of the component to reflect the updated data."},"answerExplanation":{"@type":"Comment","text":"When state changes, React Native triggers a re-render of the component to reflect the updated data."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"Which of the following is correct about updating state in a class component?","comment":{"@type":"Comment","text":"State updates in class components should be done using this.setState() to trigger re-renders properly."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"State can be directly modified","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"State updates immediately after calling setState","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"State updates are synchronous","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"State should be updated using this.setState","comment":{"@type":"Comment","text":"State updates in class components should be done using this.setState() to trigger re-renders properly."},"answerExplanation":{"@type":"Comment","text":"State updates in class components should be done using this.setState() to trigger re-renders properly."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"What happens if you try to modify props inside a child component?","comment":{"@type":"Comment","text":"Props are read-only in child components, so modifying them directly leads to errors."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"The component will update normally","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"Props will be updated automatically","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"The update will be ignored","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"React will throw an error","comment":{"@type":"Comment","text":"Props are read-only in child components, so modifying them directly leads to errors."},"answerExplanation":{"@type":"Comment","text":"Props are read-only in child components, so modifying them directly leads to errors."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"What is the correct syntax to define state in a functional component?","comment":{"@type":"Comment","text":"The useState hook is used in functional components to manage state."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"this.state = { count: 0 };","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"useState({ count: 0 })","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"state = { count: 0 }","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"const [count, setCount] = useState(0);","comment":{"@type":"Comment","text":"The useState hook is used in functional components to manage state."},"answerExplanation":{"@type":"Comment","text":"The useState hook is used in functional components to manage state."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"How do you pass a prop named title to a component named Header?","comment":{"@type":"Comment","text":"Props are passed to a React Native component as attributes inside JSX."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"<Header props.title=\"Welcome\" />","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"<Header {title} />","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"<Header @title=\"Welcome\" />","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"<Header title=\"Welcome\" />","comment":{"@type":"Comment","text":"Props are passed to a React Native component as attributes inside JSX."},"answerExplanation":{"@type":"Comment","text":"Props are passed to a React Native component as attributes inside JSX."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"What is the correct way to provide a default value for a prop in a functional component?","comment":{"@type":"Comment","text":"In React, defaultProps can be used to assign default values to props when they are not provided by the parent component. This ensures the component has a fallback value instead of undefined"},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"props.value = \"Default\"","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"const { value = \"Default\" } = props;","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"props.value || \"Default\"","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"Welcome.defaultProps = { value: \"Default\" };","comment":{"@type":"Comment","text":"In React, defaultProps can be used to assign default values to props when they are not provided by the parent component. This ensures the component has a fallback value instead of undefined"},"answerExplanation":{"@type":"Comment","text":"In React, defaultProps can be used to assign default values to props when they are not provided by the parent component. This ensures the component has a fallback value instead of undefined"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"Why does \"Cannot read property 'setState' of undefined\" occur in a class component?","comment":{"@type":"Comment","text":"In class components, this.setState needs to be explicitly bound in the constructor."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"setState is not a valid function","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"State cannot be modified","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"The component is not wrapped in a View","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"this is not bound in the constructor","comment":{"@type":"Comment","text":"In class components, this.setState needs to be explicitly bound in the constructor."},"answerExplanation":{"@type":"Comment","text":"In class components, this.setState needs to be explicitly bound in the constructor."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"What could cause a functional component to not update when state changes?","comment":{"@type":"Comment","text":"In functional components, state must be updated using the setState function returned by useState."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"State updates synchronously","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"The component is inside a View","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"State can only be changed inside a class component","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"Not using setState","comment":{"@type":"Comment","text":"In functional components, state must be updated using the setState function returned by useState."},"answerExplanation":{"@type":"Comment","text":"In functional components, state must be updated using the setState function returned by useState."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"Why does a child component not receive updated props when the parent state changes?","comment":{"@type":"Comment","text":"If the parent component does not re-render, the child does not receive updated props."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"Props are immutable","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"Only class components support props","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"React Native does not support state updates","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"The parent does not re-render","comment":{"@type":"Comment","text":"If the parent component does not re-render, the child does not receive updated props."},"answerExplanation":{"@type":"Comment","text":"If the parent component does not re-render, the child does not receive updated props."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"How do you handle user input in React Native?","comment":{"@type":"Comment","text":"React Native provides built-in event handlers like onPress for buttons and onChangeText for text inputs."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"Using event listeners","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"Using inline styles","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"Using Redux","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"Using the onPress or onChangeText handlers","comment":{"@type":"Comment","text":"React Native provides built-in event handlers like onPress for buttons and onChangeText for text inputs."},"answerExplanation":{"@type":"Comment","text":"React Native provides built-in event handlers like onPress for buttons and onChangeText for text inputs."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"Which method is used to handle button clicks in React Native?","comment":{"@type":"Comment","text":"Unlike web React, where onClick is used, React Native handles button presses using the onPress event."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"onClick","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"onTap","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"onTouch","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"onPress","comment":{"@type":"Comment","text":"Unlike web React, where onClick is used, React Native handles button presses using the onPress event."},"answerExplanation":{"@type":"Comment","text":"Unlike web React, where onClick is used, React Native handles button presses using the onPress event."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"What event handler is used to capture text input changes in React Native?","comment":{"@type":"Comment","text":"The onChangeText event is used with TextInput to capture user input in real time."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"onInput","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"onText","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"onModifyText","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"onChangeText","comment":{"@type":"Comment","text":"The onChangeText event is used with TextInput to capture user input in real time."},"answerExplanation":{"@type":"Comment","text":"The onChangeText event is used with TextInput to capture user input in real time."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"What is the correct way to prevent event propagation in React Native?","comment":{"@type":"Comment","text":"The stopPropagation() method prevents an event from bubbling up to parent components."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"Calling event.preventDefault()","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"Returning false","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"Using event.cancel","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"Calling event.stopPropagation()","comment":{"@type":"Comment","text":"The stopPropagation() method prevents an event from bubbling up to parent components."},"answerExplanation":{"@type":"Comment","text":"The stopPropagation() method prevents an event from bubbling up to parent components."}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Practice problem","text":"Which gesture handling library is commonly used in React Native?","comment":{"@type":"Comment","text":"React Native Gesture Handler is a library used for handling complex gestures in React Native."},"encodingFormat":"text/html","suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/html","text":"React Navigation","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":2,"encodingFormat":"text/html","text":"Redux","comment":{"@type":"Comment","text":"It is the wrong option"}},{"@type":"Answer","position":3,"encodingFormat":"text/html","text":"Context API","comment":{"@type":"Comment","text":"It is the wrong option"}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/html","text":"React Gesture Handler","comment":{"@type":"Comment","text":"React Native Gesture Handler is a library used for handling complex gestures in React Native."},"answerExplanation":{"@type":"Comment","text":"React Native Gesture Handler is a library used for handling complex gestures in React Native."}}}]}
React Native Multiple Choice Questions (MCQs) and Answers
Master React Native with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of React Native concepts. Begin your placement preparation journey now!
Q31
Q31 What could cause the "JSX expressions must have one parent element" error?
A
Using too many elements in JSX
B
Not wrapping JSX elements inside a parent element
C
Using JavaScript functions inside JSX
D
Not using semicolons properly
Q32
Q32 What is the preferred way to style components in React Native?
A
Using inline styles
B
Using external CSS files
C
Using the StyleSheet API
D
Using Bootstrap
Q33
Q33 What does Flexbox in React Native help with?
A
Handling animations
B
Managing UI layout and alignment
C
Writing JavaScript logic
D
Adding event handlers
Q34
Q34 What is the default flex direction in React Native?
A
row
B
column
C
row-reverse
D
column-reverse
Q35
Q35 Which of the following properties is used to create a responsive layout in React Native?
A
position
B
display
C
flex
D
overflow
Q36
Q36 What does justifyContent: 'center' do in React Native styling?
A
Aligns items horizontally in the center
B
Aligns items vertically in the center
C
Centers items inside a View
D
Removes extra spacing between elements
Q37
Q37 How do you apply multiple styles to a component in React Native?
A
Pass an array of style objects
B
Use multiple style attributes
C
Separate styles with commas
D
Use CSS classes
Q38
Q38 What is the correct way to define styles using StyleSheet.create?
A
StyleSheet.create({ myStyle: { color: 'blue' } })
B
StyleSheet({ myStyle: { color: 'blue' } })
C
Style.create({ myStyle: { color: 'blue' } })
D
new StyleSheet({ myStyle: { color: 'blue' } })
Q39
Q39 What will be the background color of a View with the following style: { backgroundColor: 'transparent' }?
A
White
B
Black
C
Transparent
D
Gray
Q40
Q40 What will happen if you set flex: 1 to a View inside a parent with flex: 1?
A
The child View will occupy the entire screen
B
The child View will be hidden
C
The child View will divide space equally with siblings
D
It will throw an error
Q41
Q41 Why is the error "StyleSheet.create is not a function" occurring?
A
Incorrect import of StyleSheet
B
StyleSheet is not supported in React Native
C
Incorrect function name
D
Styles must be defined inside the component
Q42
Q42 What could be the reason for styles not applying to a component?
A
Style object is not used
B
CSS classes are required
C
Only inline styles are supported
D
React Native does not support styling
Q43
Q43 Why does alignItems: 'center' not work as expected on a View?
A
alignItems does not exist in React Native
B
It only works if justifyContent is also used
C
It requires a parent with flex applied
D
It only works on Text components
Q44
Q44 What is the purpose of state in React Native?
A
To store local component data
B
To manage navigation
C
To handle API calls
D
To define styles
Q45
Q45 How is state defined in a functional component?
A
this.state
B
useState hook
C
setState
D
componentState
Q46
Q46 What is the key difference between state and props?
A
Props are mutable, but state is immutable
B
State is managed inside the component, while props are passed from a parent
C
Props can be changed inside the component
D
State and props are identical
Q47
Q47 What happens when state changes in a component?
A
Nothing happens
B
The component is re-rendered
C
State is reset to the initial value
D
The app crashes
Q48
Q48 Which of the following is correct about updating state in a class component?
A
State can be directly modified
B
State should be updated using this.setState
C
State updates immediately after calling setState
D
State updates are synchronous
Q49
Q49 What happens if you try to modify props inside a child component?
A
The component will update normally
B
Props will be updated automatically
C
React will throw an error
D
The update will be ignored
Q50
Q50 What is the correct syntax to define state in a functional component?
A
const [count, setCount] = useState(0);
B
this.state = { count: 0 };
C
useState({ count: 0 })
D
state = { count: 0 }
Q51
Q51 How do you pass a prop named title to a component named Header?
A
<Header title="Welcome" />
B
<Header props.title="Welcome" />
C
<Header {title} />
D
<Header @title="Welcome" />
Q52
Q52 What is the correct way to provide a default value for a prop in a functional component?
A
props.value = "Default"
B
const { value = "Default" } = props;
C
props.value || "Default"
D
Welcome.defaultProps = { value: "Default" };
Q53
Q53 Why does "Cannot read property 'setState' of undefined" occur in a class component?
A
setState is not a valid function
B
State cannot be modified
C
The component is not wrapped in a View
D
this is not bound in the constructor
Q54
Q54 What could cause a functional component to not update when state changes?
A
Not using setState
B
State updates synchronously
C
The component is inside a View
D
State can only be changed inside a class component
Q55
Q55 Why does a child component not receive updated props when the parent state changes?
A
The parent does not re-render
B
Props are immutable
C
Only class components support props
D
React Native does not support state updates
Q56
Q56 How do you handle user input in React Native?
A
Using event listeners
B
Using the onPress or onChangeText handlers
C
Using inline styles
D
Using Redux
Q57
Q57 Which method is used to handle button clicks in React Native?
A
onClick
B
onTap
C
onPress
D
onTouch
Q58
Q58 What event handler is used to capture text input changes in React Native?
A
onInput
B
onText
C
onChangeText
D
onModifyText
Q59
Q59 What is the correct way to prevent event propagation in React Native?
A
Calling event.preventDefault()
B
Calling event.stopPropagation()
C
Returning false
D
Using event.cancel
Q60
Q60 Which gesture handling library is commonly used in React Native?