Comments (3)
@sumit-pandey Please fill in the information, you have left it all empty. At least copy/paste the code that is not working and explain what happens. Thanks.
from abracadabra.
//this class based component is not converting into functional based component using abracadabra
import React, { Component } from "react";
import "./Search.css";
import PostsList from "./PostsList";
import MenuItems from "./MenuItems";
class Search extends Component {
// runs after component is mounted
state = {
searchQuery: ""
};
handleInputChange = e => {
this.setState({
searchQuery: e.target.value
});
};
render() {
return (
<div className="container">
<div className="content">
<h1 className="heading">Search</h1>
<input
type="text"
id="search"
placeholder="Insight, podcasts, or reports"
value={this.state.searchQuery}
onChange={this.handleInputChange}
/>
{/* search list */}
{this.state.searchQuery && (
<div className="searchResults">
<PostsList searchQuery={this.state.searchQuery} />
</div>
)}
{/* top catagoreis */}
<div
className="top_categories"
style={{ display: this.state.searchQuery ? "none" : "block" }}
>
<h6 style={{ fontSize: 16 }}>Top categories</h6>
<div className="top_grids">
<MenuItems />
</div>
{/* ----xxxxxxxxxx---- */}
</div>
</div>
</div>
);
}
}
export default Search;
from abracadabra.
Hi @sumit-pandey 👋
Thanks for reporting. Indeed, this class component can't be refactored into a pure functional component, because it has a state.
Under the hood, it's reactjs/react-codemod which does the conversion. If they can't handle it, Abracadabra won't propose the refactoring.
I'll suggest you raise the issue there to see if they could handle such pattern. If they do, we'll happily upgrade Abracadabra to make it work! Thanks!
from abracadabra.
Related Issues (20)
- Automatically "Convert to Template String" if we write ${} in a string HOT 2
- Convert getter / setter to member functions
- Inlining JSX removes curly braces HOT 1
- Extract refactoring runs on JSX attribute HOT 3
- Inline async arrow function misses braces HOT 1
- Abracadabra replaces system key binding HOT 3
- Extract Variable insert position doesn't right HOT 2
- change activationEvent to onLanguage
- Idea: Migrate to TypeScript plugin HOT 4
- "Change Signature" doesn't work on a nested function HOT 3
- "Add explicit type" refactoring HOT 1
- Inline variable if ternary misses parens HOT 5
- split declaration & init when working inside class
- JS and TS code without `;` is broken after refactoring HOT 3
- Abracadabra extension causes performance issues with other extensions (prettier formatting, etc.) HOT 7
- More inline variable missing parentheses edge-cases HOT 1
- Can't move class to an existing file HOT 2
- Move to new file: configure case of the new filename HOT 3
- Upgrade babel/traverse ti eliminate vulnerability. HOT 1
- Convert to Arrow Function: Does not work with a `export default function` HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from abracadabra.